Terraform-provider-aws: volume_tags on instance (sometimes) clobbers attached EBS volume tags

Created on 15 Jun 2017  ·  5Comments  ·  Source: hashicorp/terraform-provider-aws

_This issue was originally opened by @gavD as hashicorp/terraform#15302. It was migrated here as part of the provider split. The original body of the issue is below._


Terraform Version

0.9.8

 Description

I use volume_tags on an EC2 instance to set my boot volume's tags. However, for my mounted volumes, I want slightly different tags (I use MakeSnapshot: True so a custom tool makes a snapshots ONLY of the mounted volume)

Expected Behavior

MakeSnapshot: True is set on the mounted volume

Actual Behavior

Terraform SOMETIMES does what I want and SOMETIMES stripes the MakeSnapshot tag. Here's the plan output:

~ module.basic2.aws_instance.database.0
    volume_tags.%:            "10" => "9"
    volume_tags.MakeSnapshot: "True" => ""

Steps to Reproduce

Here's an example terraform config with the irrelevant parts stripped out.

resource "aws_instance" "database" {

   # ...various config here...

  root_block_device {
    volume_type = "gp2"
  }

  tags {
    Name           =  "myinstance"
  }

  # I only want these on the boot volume
  volume_tags {
    Name           = "myinstance-bootVolume"
  }
}

resource "aws_ebs_volume" "database" {

  # ... various config here...

  type              = "gp2"

  tags {
    Name           = "myinstance-dataVolume"
    MakeSnapshot   = "True"
  }
}

resource "aws_volume_attachment" "database" {
  # ... various config here ...
}

then run terraform plan

Important Factoids

  • Running in EC2 VPCs
  • Sometimes it will strip the tag from the data, sometimes it will not

References

  • GH-14019
bug servicec2 stale

Most helpful comment

This is a very annoying problem.

It could be solved by:

Only allow volume_tags to apply to block devices defined in the aws_instance resource, or shift the tags to the block_device sections.

Or add a new tagging resource that allows tags to be added to the root block device outside of the aws_instance. This ones seems like a really bad idea though.

All 5 comments

Have encountered same issue with same setup in Terraform 0.9.8 and 0.9.11.

Attached volume tags gets clobbered by the instance volume tags. Only workaround right now is to not set volume tags via the aws_instance attribute.

This is a very annoying problem.

It could be solved by:

Only allow volume_tags to apply to block devices defined in the aws_instance resource, or shift the tags to the block_device sections.

Or add a new tagging resource that allows tags to be added to the root block device outside of the aws_instance. This ones seems like a really bad idea though.

Related tickets: #729 & #770 (possibly all duplicates of the same issue?)

Marking this issue as stale due to inactivity. This helps our maintainers find and focus on the active issues. If this issue receives no comments in the next 30 days it will automatically be closed. Maintainers can also remove the stale label.

If this issue was automatically closed and you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thank you!

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!

Was this page helpful?
0 / 5 - 0 ratings