From 1598212959b8aea004080901a0ea39ec2906d8bf Mon Sep 17 00:00:00 2001 From: Nam Nguyen Date: Sat, 9 Nov 2024 21:42:58 +1000 Subject: [PATCH] fix: ignore `tags` for `aws_appautoscaling_target` Scalable targets created before 2023-03-20 may not have an assigned arn. These resource cannot use tags or participate in default_tags. To prevent terraform plan showing differences that can never be reconciled, use the lifecycle.ignore_changes meta-argument Reference: https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/appautoscaling_target --- main.tf | 5 +++-- variables.tf | 6 ++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/main.tf b/main.tf index 364e1dc..dcee575 100644 --- a/main.tf +++ b/main.tf @@ -290,9 +290,10 @@ resource "aws_appautoscaling_target" "this" { tags = var.tags lifecycle { - ignore_changes = [ + ignore_changes = var.autoscaling_tags_ignore ? [ + tags, tags_all, - ] + ] : [] } } diff --git a/variables.tf b/variables.tf index 8b49969..b14c1d3 100644 --- a/variables.tf +++ b/variables.tf @@ -590,6 +590,12 @@ variable "autoscaling_target_connections" { default = 700 } +variable "autoscaling_tags_ignore" { + description = "Scalable targets created before 2023-03-20 cannot use tags or default_tags. To prevent terraform plan showing differences that can never be reconciled, set this flag to true" + type = bool + default = false +} + ################################################################################ # Security Group ################################################################################