-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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_ebs_volume unable to handle "Name" tag #927
Comments
Hi @flypenguin Can you tell me if you are using aws_instance volume tags as well? |
hi @stack72 the and the example is completely self-contained, you can try and reproduce with this. I use the volumes in another TF project though. originally a data source is responsible for locating the correct volume and then I attach it. I had to change that as well when TF removed all the tags and refused to re-add them. |
Fixes: #927 When we ran the create, we didn't make a call to the API to Describe the volume, therefore, we were not actually setting the values to state based on what the API returned. We also only set the Tags to state if they were not nil. Therefore, the scenario of someone creating a tag with Terraform, then removing that tag (and thus no tags are left on the resource) would mean that Terraform didn't see the state drift: ``` [stacko@Pauls-MBP:~/Code/terraform-org/terraform-recreations/current-working] % terraform apply aws_ebs_volume.hashi-test: Creating... availability_zone: "" => "eu-central-1a" encrypted: "" => "<computed>" iops: "" => "<computed>" kms_key_id: "" => "<computed>" size: "" => "5" snapshot_id: "" => "<computed>" tags.%: "" => "1" tags.Name: "" => "hashi-test" type: "" => "<computed>" aws_ebs_volume.hashi-test: Still creating... (10s elapsed) aws_ebs_volume.hashi-test: Creation complete (ID: vol-01133d4a2d74aa55b) Apply complete! Resources: 1 added, 0 changed, 0 destroyed. The state of your infrastructure has been saved to the path below. This state is required to modify and destroy your infrastructure, so keep it safe. To inspect the complete state use the `terraform show` command. State path: [stacko@Pauls-MBP:~/Code/terraform-org/terraform-recreations/current-working] % terraform plan Refreshing Terraform state in-memory prior to plan... The refreshed state will be used to calculate this plan, but will not be persisted to local or remote state storage. aws_ebs_volume.hashi-test: Refreshing state... (ID: vol-01133d4a2d74aa55b) No changes. Infrastructure is up-to-date. This means that Terraform did not detect any differences between your configuration and real physical resources that exist. As a result, Terraform doesn't need to do anything. ``` This commit takes care of that but always setting the tags - d.Set handles the empty API response so we should use that: ``` % terraform apply aws_ebs_volume.hashi-test: Creating... availability_zone: "" => "eu-central-1a" encrypted: "" => "<computed>" iops: "" => "<computed>" kms_key_id: "" => "<computed>" size: "" => "5" snapshot_id: "" => "<computed>" tags.%: "" => "1" tags.Name: "" => "hashi-test" type: "" => "<computed>" aws_ebs_volume.hashi-test: Still creating... (10s elapsed) aws_ebs_volume.hashi-test: Creation complete (ID: vol-0746b8a7d4f6ac0b5) Apply complete! Resources: 1 added, 0 changed, 0 destroyed. The state of your infrastructure has been saved to the path below. This state is required to modify and destroy your infrastructure, so keep it safe. To inspect the complete state use the `terraform show` command. State path: [stacko@Pauls-MBP:~/Code/terraform-org/terraform-recreations/current-working] % terraform plan Refreshing Terraform state in-memory prior to plan... The refreshed state will be used to calculate this plan, but will not be persisted to local or remote state storage. aws_ebs_volume.hashi-test: Refreshing state... (ID: vol-0746b8a7d4f6ac0b5) The Terraform execution plan has been generated and is shown below. Resources are shown in alphabetical order for quick scanning. Green resources will be created (or destroyed and then created if an existing resource exists), yellow resources are being changed in-place, and red resources will be destroyed. Cyan entries are data sources to be read. Note: You didn't specify an "-out" parameter to save this plan, so when "apply" is called, Terraform can't guarantee this is what will execute. ~ aws_ebs_volume.hashi-test tags.%: "0" => "1" tags.Name: "" => "hashi-test" Plan: 0 to add, 1 to change, 0 to destroy. ```
…ly (#999) Fixes: #927 When we ran the create, we didn't make a call to the API to Describe the volume, therefore, we were not actually setting the values to state based on what the API returned. We also only set the Tags to state if they were not nil. Therefore, the scenario of someone creating a tag with Terraform, then removing that tag (and thus no tags are left on the resource) would mean that Terraform didn't see the state drift: ``` [stacko@Pauls-MBP:~/Code/terraform-org/terraform-recreations/current-working] % terraform apply aws_ebs_volume.hashi-test: Creating... availability_zone: "" => "eu-central-1a" encrypted: "" => "<computed>" iops: "" => "<computed>" kms_key_id: "" => "<computed>" size: "" => "5" snapshot_id: "" => "<computed>" tags.%: "" => "1" tags.Name: "" => "hashi-test" type: "" => "<computed>" aws_ebs_volume.hashi-test: Still creating... (10s elapsed) aws_ebs_volume.hashi-test: Creation complete (ID: vol-01133d4a2d74aa55b) Apply complete! Resources: 1 added, 0 changed, 0 destroyed. The state of your infrastructure has been saved to the path below. This state is required to modify and destroy your infrastructure, so keep it safe. To inspect the complete state use the `terraform show` command. State path: [stacko@Pauls-MBP:~/Code/terraform-org/terraform-recreations/current-working] % terraform plan Refreshing Terraform state in-memory prior to plan... The refreshed state will be used to calculate this plan, but will not be persisted to local or remote state storage. aws_ebs_volume.hashi-test: Refreshing state... (ID: vol-01133d4a2d74aa55b) No changes. Infrastructure is up-to-date. This means that Terraform did not detect any differences between your configuration and real physical resources that exist. As a result, Terraform doesn't need to do anything. ``` This commit takes care of that but always setting the tags - d.Set handles the empty API response so we should use that: ``` % terraform apply aws_ebs_volume.hashi-test: Creating... availability_zone: "" => "eu-central-1a" encrypted: "" => "<computed>" iops: "" => "<computed>" kms_key_id: "" => "<computed>" size: "" => "5" snapshot_id: "" => "<computed>" tags.%: "" => "1" tags.Name: "" => "hashi-test" type: "" => "<computed>" aws_ebs_volume.hashi-test: Still creating... (10s elapsed) aws_ebs_volume.hashi-test: Creation complete (ID: vol-0746b8a7d4f6ac0b5) Apply complete! Resources: 1 added, 0 changed, 0 destroyed. The state of your infrastructure has been saved to the path below. This state is required to modify and destroy your infrastructure, so keep it safe. To inspect the complete state use the `terraform show` command. State path: [stacko@Pauls-MBP:~/Code/terraform-org/terraform-recreations/current-working] % terraform plan Refreshing Terraform state in-memory prior to plan... The refreshed state will be used to calculate this plan, but will not be persisted to local or remote state storage. aws_ebs_volume.hashi-test: Refreshing state... (ID: vol-0746b8a7d4f6ac0b5) The Terraform execution plan has been generated and is shown below. Resources are shown in alphabetical order for quick scanning. Green resources will be created (or destroyed and then created if an existing resource exists), yellow resources are being changed in-place, and red resources will be destroyed. Cyan entries are data sources to be read. Note: You didn't specify an "-out" parameter to save this plan, so when "apply" is called, Terraform can't guarantee this is what will execute. ~ aws_ebs_volume.hashi-test tags.%: "0" => "1" tags.Name: "" => "hashi-test" Plan: 0 to add, 1 to change, 0 to destroy. ```
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! |
I am using aws_ebs_volume to create volumes and attach "Name" tags to them. Unfortunately the resource seems completely oblivious if you remove the tag after volume creation - it will not re-add it.
That in itself would not be a problem, had terraform not removed all our volume tags in version 0.9.5 I think (I guess this bug was fixed, hopefully). But now I still cannot use TF to re-add the tags automatically, since the bug exists at least for two versions.
We are using the tags to trigger certain actions (backups, to be precise) on the volumes, so the existance of those tags is really important to us.
Terraform Version
0.9.8 (and at least two versions before)
Affected Resource(s)
To my knowledge, at least:
Terraform Configuration Files
Steps to reproduce
terraform apply
)terraform apply
)Expected Behavior
Actual Behavior
References
maybe related to
The text was updated successfully, but these errors were encountered: