Skip to content
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

volume_tags on instance (sometimes) clobbers attached EBS volume tags #884

Closed
hashibot opened this issue Jun 15, 2017 · 6 comments · Fixed by #15474
Closed

volume_tags on instance (sometimes) clobbers attached EBS volume tags #884

hashibot opened this issue Jun 15, 2017 · 6 comments · Fixed by #15474
Labels
bug Addresses a defect in current functionality. service/ec2 Issues and PRs that pertain to the ec2 service. stale Old or inactive issues managed by automation, if no further action taken these will get closed.

Comments

@hashibot
Copy link

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

@hashibot hashibot added the bug Addresses a defect in current functionality. label Jun 15, 2017
@kevinprince
Copy link

kevinprince commented Jul 22, 2017

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.

@bflad bflad added the service/ec2 Issues and PRs that pertain to the ec2 service. label Jan 28, 2018
@cregkly
Copy link

cregkly commented Apr 23, 2018

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.

@tdmalone
Copy link
Contributor

tdmalone commented Jul 1, 2018

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

@github-actions
Copy link

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!

@github-actions github-actions bot added the stale Old or inactive issues managed by automation, if no further action taken these will get closed. label Jun 21, 2020
@ghost
Copy link

ghost commented Aug 21, 2020

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!

@ghost ghost locked and limited conversation to collaborators Aug 21, 2020
@YakDriver
Copy link
Member

We have merged a fix to the volume_tags issue in #15474. We have added tests to cover the issues observed. Please note that using volume_tags in aws_instance is not compatible with using tags in aws_ebs_volume. You need to use one or the other. Prior to this fix, even following this rule, you would encounter errors. Along with the fix, we've added tags to the root_block_device and ebs_block_device configuration blocks in aws_instance.

Now that the fix is in place, if you find any problems with volume_tags, let us know by opening a new issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. service/ec2 Issues and PRs that pertain to the ec2 service. stale Old or inactive issues managed by automation, if no further action taken these will get closed.
Projects
None yet
6 participants