Hello, I can not find any possible combination, where I can use data template_file
variables and after init
variables.
Basically I’m using Launch Template to manage the user data
, but currently I can not use as mentioned above both types of variables, so what I’m looking for is, something like this.
#!/bin/bash
export ID=$(curl -s http://169.254.169.254/latest/meta-data/instance-id)
aws ec2 create-tags --resources ${ID} --tags Key=Name,Value="dev instance: ${region}-${zone}"
So in my bash script, I’m fetching the newly created instance id
so I can tag it, however this action is not possible while terraform apply
, but variables like region
and zone
I would like to pass through data template_file
like:
data "template_file" "launch_template_userdata" {
template = file("${path.module}/templates/userdata.sh.tpl")
vars = {
zone = local.zone
region = local.region
}
}
How can I combine this actions, or it even possible?