It appears that in some version >0.7.7 that HCL multiline is not getting honored like it is in hashicorp/hcl test fixtures. I used to be able to have a variable with a quoted (literal) multiline like:
$ cat test.tf
variable "multiline-example" {
default = "---- this is line one
this is line two with literal indenting
this is line three"
}
And that is valid up to 0.7.7, but now is not:
$ /usr/lib/terraform-0.7.7 version
Terraform v0.7.7
Your version of Terraform is out of date! The latest version
is 0.8.4. You can update by downloading from www.terraform.io
$ /usr/lib/terraform-0.7.7 get
$ /usr/lib/terraform-0.8.4 version
Terraform v0.8.4
$ /usr/lib/terraform-0.8.4 get
Error loading Terraform: Error loading config: Error parsing /home/rremer/source/rremer/tf-multiline-var-bug/test.tf: At 4:33: literal not terminated
I tried fiddling with heredoc-style delimeters to no avail as well. If this behavior has changed purposefully, I'd like to request we document that (perhaps in interpolation syntax and getting-started/variables). If this is a regression (which I personally think it is), hopefully this helps!
This is covered in the upgrade guide (the first item): https://www.terraform.io/upgrade-guides/0-8.html
Heredocs should work, if you post an example that doesn't work I'd be happy to take a look though!
This is from Linux Academy.. doesn't work
Failed to load root config module: Error parsing /terransible/main.tf: At 312:38: literal not terminated
provisioner "local-exec" {
command = "cat <<EOF > aws_hosts
[dev]
${aws_instance.dev.public_ip}
[dev:vars]
s3code=${aws_s3_bucket.code.bucket}
EOF"
}
@skyscooby the changes from .7 to .8 are covered in the later module titled, "Lecture: Upgrading from Terraform v0.7 to v0.8"
you have to enclose heredocs with additional delimiters.
specifically:
provisioner "local-exec" {
command = <<EOD
cat <<EOF > aws_hosts
[dev]
${aws_instance.dev.public_ip}
[dev:vars]
s3code=${aws_s3_bucket.code.bucket}
EOF
EOD
}
I'm still having issues with this even after updating the delimiters. Any help would be appreciated. Thanks!
provisioner "local-exec" {
command = <<EOD
cat <
${aws_instance.dev.public_ip}
[dev:vars]
s3code=${aws_s3_bucket.code.bucket}
EOF
EOD
}
And the error I get is:
Error: Failed to load root config module: Error parsing /home/oem/Documents/Development/terraform/terransible/main.tf: key 'EOD' expected start of object ('{') or assignment ('=')
@servo83 please take a second look at the differences between the snippet you provided and the examples shown here - specifically, the cat line.
Hi
Am getting Error running fmt: In ec2.tf: At 5:2: literal not terminated
my ec2.tf file looks like
1 provider "aws" {
2 access_key = "${var.access_key}"
3 secret_key = "${var.secret_key"
4 region = "${var.region}"
5 }
6
7 resource "aws_instance" "myfirstinst" {
8 ami = "${lookup(var.ami, var.region)}"
9 instance_type = "t2.micro"
10 key_name = "testkey"
11 }
12
13 resource "aws_eip" "staticip" {
14 instance = "${aws_instance.myfirstinst.id}"
15 vpc = "true"
16 }
~
I created a variable file for this, that is variable.tf. output of this file is
1 variable "access_key" {
2 description = "AWS access key"
3 }
4
5 variable "secret_key" {
6 description = "AWS secret key"
7 }
8
9 variable "region" {
10 description = "setting up AWS deafult region"
11 default = "ap-south-1"
12 }
13
14 variable "region_list" {
15 description = "availability zones"
16 default = ["ap-south-1a", "ap-south-1b"]
17 }
18
19 variable "ami" {
20 type = "map"
21
22 default = {
23 ap-south-1 = "ami-e60e5a89"
24 ap-southeast-1 = "ami-e2adf99e"
25 }
26
27 description = " the AMI to use "
28 }
~
~
~
My terraform version is
Terraform v0.11.5
provider.aws v1.13.0
could you please anyone help me out this.
Thank you
I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
Most helpful comment
@skyscooby the changes from .7 to .8 are covered in the later module titled, "Lecture: Upgrading from Terraform v0.7 to v0.8"
you have to enclose heredocs with additional delimiters.
specifically: