From f5f56a2a6a9316cf5d34306cced59e7462440591 Mon Sep 17 00:00:00 2001 From: Alvaro Lopez <5921727+alv-lop@users.noreply.github.com> Date: Tue, 10 Jan 2023 12:40:26 +0000 Subject: [PATCH] fix(ec2): aws_launch_template default version should change as the launch template configuration changes over time (#97) Signed-off-by: Alvaro Lopez Hernandez --- modules/ec2/main.tf | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/modules/ec2/main.tf b/modules/ec2/main.tf index 1cab76a..7192305 100644 --- a/modules/ec2/main.tf +++ b/modules/ec2/main.tf @@ -139,11 +139,12 @@ data "template_cloudinit_config" "cloud_init" { } resource "aws_launch_template" "kong" { - name_prefix = local.name - image_id = var.ami_id - instance_type = var.instance_type - key_name = var.key_name - user_data = var.user_data == null ? base64encode(data.template_cloudinit_config.cloud_init.rendered) : base64encode(var.user_data) + name_prefix = local.name + image_id = var.ami_id + instance_type = var.instance_type + key_name = var.key_name + user_data = var.user_data == null ? base64encode(data.template_cloudinit_config.cloud_init.rendered) : base64encode(var.user_data) + update_default_version = true iam_instance_profile { name = var.iam_instance_profile_name @@ -183,7 +184,7 @@ resource "aws_autoscaling_group" "kong" { launch_template { name = aws_launch_template.kong.name - version = "$Latest" + version = aws_launch_template.kong.latest_version } desired_capacity = var.asg_desired_capacity