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(“script.sh”)

script.sh
sudo yum update -y

while creating resource it is simply skipping userdata.

Also tried below format but did not work

user_data = “${file(“script.sh”)}”

Appreciate for your help!!!

Thanks,
Ramesh

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

script.sh:

#!/bin/bash
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?