amazon web services - How can I initialice an instance with cloud-init on Terraform -


i trying initilice aws instances using cloud-init, use next terraform code test:

variable "hostname"    {} variable "domain_name" {}   variable "filename" {   default = "cloud-config.cfg" }  data "template_file" "test" {   template = <<eof #cloud-config hostname: $${hostname} fqdn: $${fqdn} mounts:   - [ ephemeral, null ] output:   all: '| tee -a /var/log/cloud-init-output.log' eof    vars {     hostname = "${var.hostname}"     fqdn     = "${format("%s.%s", var.hostname, var.domain_name)}"   } }  data "template_cloudinit_config" "test" {   gzip          = false   base64_encode = false    part {     filename     = "${var.filename}"     content_type = "text/cloud-config"     content      = "${data.template_file.test.rendered}"   } }   resource "aws_instance" "bootstrap2" {     ami = "${var.aws_centos_ami}"     availability_zone = "eu-west-1b"     instance_type = "t2.micro"     key_name = "${var.aws_key_name}"     security_groups = ["${aws_security_group.bastion.id}"]     associate_public_ip_address = true     private_ip = "10.0.0.12"     source_dest_check = false     subnet_id = "${aws_subnet.eu-west-1b-public.id}"     triggers {       template = "${data.template_file.test.rendered}"     }      tags {             name = "bootstrap2"         } } 

but failing triggers inside "bootstrap" resource. how can aprovisione instance cloud-config defined up?

triggers not valid argument aws_instance resource. usual way pass configuration cloud-init via user_data argument, this:

resource "aws_instance" "bootstrap2" {   ami = "${var.aws_centos_ami}"   availability_zone = "eu-west-1b"   instance_type = "t2.micro"   key_name = "${var.aws_key_name}"   security_groups = ["${aws_security_group.bastion.id}"]   associate_public_ip_address = true   private_ip = "10.0.0.12"   source_dest_check = false   subnet_id = "${aws_subnet.eu-west-1b-public.id}"    # pass templated configuration cloud-init   user_data = "${data.template_file.test.rendered}"    tags {     name = "bootstrap2"   } } 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -