I have a lambda function that triggers every 24 hours to create an instance based on a specific LaunchTemplate.
import boto3
AWS_REGION = XXXX
EC2_CLIENT = boto3.resource('ec2', region_name=AWS_REGION)
def lambda_handler(event, context):
instance = EC2_CLIENT.create_instances(
LaunchTemplate={
'LaunchTemplateName': 'ingestion-rclone'
},
MinCount=1,
MaxCount=1,
)
I have this source code in my Terraform and it creates it's own ZIP from it.
data "archive_file" "zip_the_python_code" {
type = "zip"
source_dir = "${path.module}/python"
output_path = "${path.module}/python/lambda_function.zip"
depends_on = [aws_launch_template.ingest_server_lt]
}
Do I have any options on how I can populate the 'LaunchTemplateName' or the alternative 'LaunchTemplateId' value with variables from the TerraForm resources before the python get's zipped up?
I've tried something like this but it just take the text as it to the lambda.
LaunchTemplate={
'LaunchTemplateId': '${aws_launch_template.ingest_server_lt.id}'
},