Long statements in Terraform that go across multiple lines?

3,037 views
Skip to first unread message

Sean Bigdatafun

unread,
Jun 6, 2016, 1:09:49 PM6/6/16
to Terraform
Here is something I want to do (but ignore this particular example).

My question here is how to break the long line into multiple lines?

-----
some_variables.var
variable "my_subnet_cird" {
}


------------

subnet_list = ["${split(",", var.my_subnet_cird)}"]


How may I make one statement across multiple lines in Terraform? 

shorn....@gmail.com

unread,
Jun 6, 2016, 10:43:05 PM6/6/16
to Terraform
I'm interested in figuring out how to split lines too.  

My context is long user_data lines caused by needing to do replacement in cloud-init scripts:
resource "aws_launch_configuration" "jenkins-master-server-launch-config" {
  ...
  user_data = "${replace(file(\"server-scripts/server-jenkins-asg-provision.sh\"), \"EBS_VOLUME_ID\", aws_ebs_volume.jenkins-master-ebs-volume.id) }"

shorn....@gmail.com

unread,
Jun 9, 2016, 10:52:22 PM6/9/16
to Terraform
Turns out TF already has a way to deal with this for my situation:

resource "aws_launch_configuration" "jenkins-master-server-launch-config" {
  ...
  user_data = "${template_file.jenks-master-server-provision-template.rendered}"
}

resource "template_file" "jenks-master-server-provision-template" {
  template = "${file("server-scripts/server-jenkins-provision.sh")}"
  vars {
    ROUTE53_ZONE_ID = "${aws_route53_zone.new-flux-dev-route53-zone.zone_id}"
  }
}
Reply all
Reply to author
Forward
0 new messages