-
Notifications
You must be signed in to change notification settings - Fork 9.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
aws_ecs_service fails adding tags on resources created before AWS introduced tags on ECS #7373
Comments
Hi @ebarault 👋 Sorry for the trouble here. Unfortunately this behavior is determined by the ECS service itself. While opting in to the longer format ARNs allows new ECS clusters and services to take advantage of the new tagging feature, existing ECS clusters and services must be migrated (e.g. recreated) to also utilize the same feature. Older ECS services in particular have an incompatible ARN for tagging due to its ambiguous format not including the cluster. For more information about the ECS ARN changes and migration strategies, please see these AWS references:
Since the ECS service does not have functionality to automatically migrate existing infrastructure to the longer ARN format for the Terraform AWS provider to implement nor would we setup any form automatic ECS cluster/service recreation (causing downtime) or migration (complexity), I'm going to close this issue. Please do reach out if we are missing anything here though. |
Wouldnt it be better to make it a "recreate" change if we detect the short to long format change? That way it does not "plan" fine but then break on apply. |
Additionally, is there any way to have the Or is there another, easier way to accomplish this? |
@pecigonzalo Are you suggesting that the Its technically possible via
@barnharts4 since Terraform is designed to be declarative, we strongly prefer the Terraform AWS provider to error in cases where it cannot perform the actions required to converge on a given configuration. Typically if a resource does not converge for a configuration, we would consider that a bug as that is a general design tenet for Terraform that operators have grown to expect. If we were to bypass the specific
If you already have a Terraform module, you can do something like the below (sorry if its a little off, untested) to create a new boolean variable that is used to determine whether or not to include tags per module declaration. # calling configuration
module "my_ecs_service" {
# ... other configuration ...
tagging_disabled = "true"
}
# module configuration
variable "tagging_disabled" {
default = "false"
}
resource "aws_ecs_service" "example" {
# ... other configuration ...
tags = "${
var.tagging_disabled == "true" ?
map() :
map(
"TagKey1", "TagValue1",
)
}"
} Omitting the new variable allows new ECS services to be appropriately tagged, while older ECS services age out over time and the flag can be removed when its no longer necessary. As a side note: we will have the ability to display warnings instead of binary success/error after Terraform 0.12, the Terraform Provider SDK is updated with that enhancement, and then the Terraform AWS Provider is updated with that SDK. Although even with the ability for warnings, operators would be still receiving that warning every apply in this scenario, should the error be converted to a warning. |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks! |
Terraform Version
Terraform v0.11.11
terraform-aws-provider 1.57.0
Affected Resource(s)
Terraform Configuration Files
Output
Expected Behavior
would create tags
Actual Behavior
fails with the above message
Steps to Reproduce
Log in as root account, and opt in for new ARN and resource ID format.
Add tag to an ECS service created before AWS introduced tags on ECS services without the terraform aws_ecs_service module
terraform apply
References
#6481
The text was updated successfully, but these errors were encountered: