Description
Description
- ✋ I have searched the open/closed issues and my issue is not listed.
After upgrading to v6.x of this module, an explicitly-specified tag isn't being applied to the instance.
Versions
- Module version [Required]:
6.0.1
- Terraform version:
v1.12.2
- Provider version(s):
registry.terraform.io/hashicorp/aws v6.0.0
Reproduction Code [Required]
module "main_ec2_instance" {
source = "terraform-aws-modules/ec2-instance/aws"
version = "~> 6.0.0"
ami = "ami-0c00c714c7f84b49d"
instance_type = "t3.medium"
tags = {
Name = "my.custom.name"
}
}
Steps to reproduce the behavior:
- Apply the above with v5.x of the provider.
- Apply the above with v6.x of the provider.
Expected behavior
I'd expect my instance to end up with a Name
tag with value my.custom.name
Actual behavior
Terraform tries to remove the Name
tag entirely; the diff shows null
as the value.
Terminal Output
I manually stripped out information specific to my project from the below.
# REDACTED.aws_instance.this[0] will be updated in-place
~ resource "aws_instance" "this" {
id = "REDACTED"
~ tags = {
~ "Name" = "my.custom.name" -> null
}
~ tags_all = {
- "Name" = "my.custom.name"
} -> (known after apply)
# (37 unchanged attributes hidden)
# (9 unchanged blocks hidden)
}
Additional context
The changelog for v6.0.0 (https://github.com/terraform-aws-modules/terraform-aws-ec2-instance/releases/tag/v6.0.0) shows that this might have been intentional:
Correct tag precedence ordering (least specific to most specific)
However, I can't understand why this module is trying to forcefully override a tag that I have explicitly provided.
Here's the relevant code AFAICT:
terraform-aws-ec2-instance/main.tf
Lines 10 to 14 in a299529
I think it would be much more sensible for the Name
tag to be listed earlier so that explicit tags that I provide take precedence.