I currently have custom AWS AMI images and Terraform is not able to execute a script or inline code in the user_data section. It works for an AWS AMI image but not when I use my own.
data "template_file" "user_data" {
template = "${file("sample")}"
}
resource "aws_launch_configuration" "test" {
image_id = "ami-xxxxxx"
instance_type = "t2.medium"
security_groups = ["xxxxx", "xxxxxxx"]
key_name = "xxxxxxx"
}
resource "aws_instance" "ZC1" {
ami = "ami-xxxxxxx" #ZC AMI IMAGE
instance_type = "t2.medium"
subnet_id = "subnet-xxxxx"
private_ip = "x.x.x.x"
key_name = "xxxxxx"
vpc_security_group_ids = ["xxxxx", "xxxxxxx"]
user_data = "${data.template_file.user_data.rendered}"
tags {
"Name" = "Terraform Script Test"
}
}