Hey,
Below is the sample code I got and trying to pass user_data to the EC2 instance, but facing issues. Is there anyway to get help on this?
resource "aws_instance" "ec2" {
ami = "${var.instance_ami}"
instance_type = "${var.instance_type}"
key_name = "${var.key_name}"
subnet_id = "${var.public_subnet_id_1_mod}"
vpc_security_group_ids = [ "${var.vpc_security_group_public_id}" ]
user_data = << EOF
#!/bin/bash
yum update -y
yum install httpd -y
service httpd start
chkconfig httpd on
cd /var/www/html
echo "<html><h1>Hello Cloud Gurus Welcome To My Webpage</h1></html>" >
index.html
EOF
tags = {
"${var.tag_key_1}" = "${var.tag_value_1}"
}
}
Below error messages keep getting
S C:\Users\12016\Documents\test\tf\tf-cloud-infra-coe\environments\intuit> terraform init
Initializing modules...
Error: Invalid expression
On ..\..\ec2\main.tf line 9: Expected the start of an expression, but found an
invalid expression token.
Error: Invalid block definition
On ..\..\ec2\main.tf line 13: A block definition must have block content
delimited by "{" and "}", starting on the same line as the block header.
Error: Invalid block definition
On ..\..\ec2\main.tf line 14: A block definition must have block content
delimited by "{" and "}", starting on the same line as the block header.
Error: Argument or block definition required
On ..\..\ec2\main.tf line 15: An argument or block definition is required
here. To set an argument, use the equals sign "=" to introduce the argument
value.
Error: Argument or block definition required
On ..\..\ec2\main.tf line 17: An argument or block definition is required
here. To set an argument, use the equals sign "=" to introduce the argument
value.
Error: Argument or block definition required
On ..\..\ec2\main.tf line 18: An argument or block definition is required
here. To set an argument, use the equals sign "=" to introduce the argument
value.
Error: Invalid expression
On ..\..\ec2\main.tf line 9: Expected the start of an expression, but found an
invalid expression token.
Error: Invalid block definition
On ..\..\ec2\main.tf line 13: A block definition must have block content
delimited by "{" and "}", starting on the same line as the block header.
Error: Invalid block definition
On ..\..\ec2\main.tf line 14: A block definition must have block content
delimited by "{" and "}", starting on the same line as the block header.
Error: Argument or block definition required
On ..\..\ec2\main.tf line 15: An argument or block definition is required
here. To set an argument, use the equals sign "=" to introduce the argument
value.
Error: Argument or block definition required
On ..\..\ec2\main.tf line 17: An argument or block definition is required
here. To set an argument, use the equals sign "=" to introduce the argument
value.
Error: Argument or block definition required
On ..\..\ec2\main.tf line 18: An argument or block definition is required
here. To set an argument, use the equals sign "=" to introduce the argument
value.
Error: Invalid expression
On ..\..\ec2\main.tf line 9: Expected the start of an expression, but found an
invalid expression token.
Its bit urgent and and greatly appreciated if some one could help at the earliest and thank you so much for your great favor in advance,
Regards,
Latha