7
votes

i'm trying to create a kubernetes cluster from kops using terraform,following code is a part of infrastructure, i'm trying to create the name concatenate with two variables, and i'm getting illegal char error line two, error happens because im trying to define the name with concatenate variables. is it possible in terraform?

resource "aws_autoscaling_group" "master-kubernetes" {
  name                 = "master-"${var.zone}".masters."${var.cluster_name}""
  launch_configuration = "${aws_launch_configuration.master-kubernetes.id}"
  max_size             = 1
  min_size             = 1
  vpc_zone_identifier  = ["${aws_subnet.subnet-kubernetes.id}"]
2

2 Answers

8
votes

Try this:

resource "aws_autoscaling_group" "master-kubernetes" {
  name = "master-${var.zone}.masters.${var.cluster_name}"
  # ... other params ...
}
7
votes

With latest terraform 0.12.x terraform format doc , you could do better like:

resource "aws_autoscaling_group" "master-kubernetes" {
    name = format("master-%s.masters.%s", var.zone, var.cluster_name)
}