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"
}
}
#cloud-config
snippet? This sort of configuration is usually handled by thecloud-init
package and needs to be installed and configured on your image (it is available by default on most popular AMIs). Can you edit your question to provide some more information on how the AMI is build or where it comes from and what the user_data looks like? – Andy Shinn