Userdata issue while creating EC2 instance

I am using 0.12.20 version. I am calling script using file function through userdata and getting below error. It was working 0.12.10 version. not sure what is the issue. Can you please suggest?

resource “aws_instance” “xxxxxx” {
user_data = file(“”)
sudo yum update -y

while creating resource it is simply skipping userdata.

Also tried below format but did not work

user_data = “${file(“”)}”

Appreciate for your help!!!


I would go with user_data = file(“./”)

yum update -y

The “#!” (aka hashbang) tells the OS which interpreter to use for the script.
Userdata script is executed during first VM boot as root, so sudo is not required.
Output from execution can be found in /var/log/cloudinit.log on the newly created VM.

When you say “skipping userdata”, do you mean that Terraform is ignoring the parameter, or that the created VM doen’t run yum update?

@ bentterp, thanks for your help. I had similar problem and that has been solved.
user_data = file(“./”)