Comments (11)
I had the exact same issue where I got to the Deploy a Single Web Server
example on page 39. After typing the updated program, I ran terraform graph to look at the dependencies and got the error: main.tf: At 29:1: heredoc not terminated
. An inital search brought me here, but I was unable to resolve the problem with the information listed in this issue. However, a few more searches and I came across this issue in the Terraform repo: hashicorp/terraform/issues/4835 where phinze says: the consistent behavior I found was that the heredoc terminates only when a line contains the terminator with no trailing space.
. After removing a trailing space after the second EOF, I did not have any more issues.
from terraform-up-and-running-code.
Indeed, the issue was caused by a trailing space after EOD
EOF
EOD
After removing trailing space, the issue was solved
from terraform-up-and-running-code.
Which example are you actually running? Could you post the full code? There is no chapter2/single_server/main.tf
in this repo.
Also, the examples in this repo have not yet been updated to work with Terraform 0.9, which is enforced via the required_version
setting. Even if I remove that check from code/terraform/02-intro-to-terraform-syntax/one-webserver/main.tf
, the plan
command works just fine with Terraform 0.9.3. Is it possible you have a copy/paste error?
from terraform-up-and-running-code.
I type the code myself without relying on the code in this repo so sorry if the issue is not about the provided code itself.
This issue is related to #12 where you can find the code I use. The reason why there is no hyphen in #12 is because of this parsing error.
The parsing disappear if the closing statement is -EOF
instead of EOF
. I'll try it as soon as possible when I have a computer available.
from terraform-up-and-running-code.
Sounds good. Keep me posted.
from terraform-up-and-running-code.
I tried with the following code:
# Single Server Deployment
provider "aws" {
region = "us-east-1"
}
resource "aws_security_group" "webserver" {
name = "terraform-example-webserver"
ingress {
from_port = 8080
to_port = 8080
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
}
resource "aws_instance" "example" {
tags {
Name = "terraform-example"
}
ami = "ami-f4cc1de2"
instance_type = "t2.micro"
vpc_security_group_ids = ["${aws_security_group.webserver.id}"]
user_data = <<-EOF
#!/bin/bash
echo "Hello, Terraform!" > index.html
nohup busybox httpd -f -p 8080 &
-EOF
}
It is parsed just fine by terraform but the web server does not kick in.
That's weird, I just downloaded the binary for macOS from the Terraform website which gave me the version 0.9.3.
I looked into the doc and I could only find this url https://www.terraform.io/docs/configuration/syntax.html where it is mentioned:
Multiline strings can use shell-style "here doc" syntax, with the string starting with a marker like <<EOF and then the string ending with EOF on a line of its own. The lines of the string and the end marker must not be indented.
from terraform-up-and-running-code.
The syntax is <<-EOF...EOF
as shown in this example.
from terraform-up-and-running-code.
There are something really weird with what happened. I was able to reproduce the parsing error 100% of the time then I copy pasted the example from the repo, no parsing error! Then I undo the copy paste to go back to the version with parsing error and....... impossible to reproduce it, it just works. I'm really puzzled, my best bet was a whitespace between <<-
and EOF
and when I fixed it I may have not saved the file so I thought it was broken, but still.... I tried several time.
Anyway let's close the issue, sorry for losing your time.
As I was not able to find it in the official documentation, it could be a good thing to add a mention of it for an update of the book. In the meantime I submitted a PR to add documentation for it: hashicorp/hcl#195
from terraform-up-and-running-code.
Yea, the heredoc stuff is whitespace sensitive, so if some tab or space got caught in the mix, it might break things in a way that's hard to see.
Good call on the HCL PR!
from terraform-up-and-running-code.
this was also my error.. thanks @Joshua-Rowe
from terraform-up-and-running-code.
trailing spaces it is - thank you
from terraform-up-and-running-code.
Related Issues (20)
- EC2 instance not responding on port 8080 HOT 3
- Issue with code update for EC2 HOT 3
- Terraform Up and Running, 3rd Edition, Chapter 4, Modularizing MySQL HOT 3
- Chapter 3: How to Manage Terraform State
- Ch7: K8s example doesn't start HOT 1
- failed to lock s3 state: 2 errors occurred:
- Looking for an full example
- Chapter 3 - Isolation Via Workspaces HOT 1
- Chapter 3 HOT 3
- Chapter 3: webserver-cluster ALB unable to access
- unit tests fail in chapter 7 HOT 5
- Why this web server cluster definition doesn't have backend configuration? HOT 2
- Ed. 2, Ch. 4 - Terraform modules. Remote state location for webserver uses key for mysql HOT 1
- Chapter 2, 3rd Edition, failed to retrieve auto scaling groups HOT 4
- Chapter 7, 3rd edition - IAM role required to create new AWS account failed to allow login acces HOT 1
- Chapter 2 - "Deploy a Single Server" needs updating now that EC2 classic is retired. HOT 3
- Chapter-3 - webserver not showing proper html format. HOT 2
- Chapter 2, 3rd Edition: one-webserver ended up with 2 running instances HOT 2
- aws_launch_configuration: "couldn't find resource" on terraform apply HOT 2
- Chapter 5 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from terraform-up-and-running-code.