Skip to content

Commit

Permalink
fix: ignore tags for aws_appautoscaling_target
Browse files Browse the repository at this point in the history
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
  • Loading branch information
namnd committed Nov 9, 2024
1 parent e6b5d79 commit 1598212
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 3 additions & 2 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -290,9 +290,10 @@ resource "aws_appautoscaling_target" "this" {
tags = var.tags

lifecycle {
ignore_changes = [
ignore_changes = var.autoscaling_tags_ignore ? [
tags,
tags_all,
]
] : []
}
}

Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
################################################################################
Expand Down

0 comments on commit 1598212

Please sign in to comment.