Community Note
- Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
- Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
- If you are interested in working on this issue or have submitted a pull request, please leave a comment
Terraform CLI and Terraform AWS Provider Version
Terraform v0.14.4
- provider registry.terraform.io/hashicorp/aws v3.23.0
Affected Resource(s)
- aws_ebs_volume
- aws_volume_attachment
- aws_instance
Terraform Configuration Files
resource "aws_instance" "web" {
ami = "ami-089668cd321f3cf82"
instance_type = "t3.micro"
availability_zone = "us-west-2a"
lifecycle {
ignore_changes = [
root_block_device,
]
}
}
resource "aws_ebs_volume" "example1" {
availability_zone = "us-west-2a"
tags = {
Name = "example1"
}
}
resource "aws_volume_attachment" "example1" {
device_name = "/dev/sdh"
volume_id = aws_ebs_volume.example1.id
instance_id = aws_instance.web.id
}
Expected Behavior
The first apply and subsequent applies result in an EBS volume with a "Name" tag set to "example1".
Actual Behavior
The first apply creates the volume with the correct tag, but subsequent applies alternatively remove and recreate the tag.
Steps to Reproduce
terraform apply. The volume will be created correctly with the "Name" tag set to "example1".
terraform apply again. The "Name" tag will be removed from the volume.
terraform apply again. The "Name" tag will be added to the volume.
terraform apply again. The "Name" tag will be removed from the volume.
terraform apply again. The "Name" tag will be added to the volume.
Important Factoids
Applies that remove the tag from the volume have the following plan. This is unexpected, because the instance resource does not specify volume_tags:
Terraform will perform the following actions:
# aws_instance.web will be updated in-place
~ resource "aws_instance" "web" {
id = "i-06ccbb7893d13d8cf"
tags = {}
~ volume_tags = {
- "Name" = "example1" -> null
}
# (26 unchanged attributes hidden)
# (5 unchanged blocks hidden)
}
Plan: 0 to add, 1 to change, 0 to destroy.
Removing root_block_device from the ignored changes on aws_instance will prevent volume tags from being removed. However, I'm seeing other examples in my Terraform environment of tags being removed from volumes which do not ignore changes to root_block_device. This was just the first example that I could reproduce simply.
Community Note
Terraform CLI and Terraform AWS Provider Version
Terraform v0.14.4
Affected Resource(s)
Terraform Configuration Files
Expected Behavior
The first apply and subsequent applies result in an EBS volume with a "Name" tag set to "example1".
Actual Behavior
The first apply creates the volume with the correct tag, but subsequent applies alternatively remove and recreate the tag.
Steps to Reproduce
terraform apply. The volume will be created correctly with the "Name" tag set to "example1".terraform applyagain. The "Name" tag will be removed from the volume.terraform applyagain. The "Name" tag will be added to the volume.terraform applyagain. The "Name" tag will be removed from the volume.terraform applyagain. The "Name" tag will be added to the volume.Important Factoids
Applies that remove the tag from the volume have the following plan. This is unexpected, because the instance resource does not specify
volume_tags:Removing
root_block_devicefrom the ignored changes onaws_instancewill prevent volume tags from being removed. However, I'm seeing other examples in my Terraform environment of tags being removed from volumes which do not ignore changes toroot_block_device. This was just the first example that I could reproduce simply.