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

aws_instance volume_tags conflict with aws_ebs_volume tags for attached volumes in a module #14462

Closed
kojiromike opened this issue May 13, 2017 · 3 comments

Comments

@kojiromike
Copy link

Terraform Version

0.9.5

Affected Resource(s)

Please list the resources as a list, for example:

  • aws_instance
  • aws_ebs_volume
  • aws_volume_attachment

Terraform Configuration Files

  1. A file in a non-root module:
resource "aws_instance" "test" {
  ami               = "ami-20328b40"
  availability_zone = "us-west-2a"
  instance_type     = "t2.micro"
  subnet_id         = "subnet-850585e2"
  key_name          = "michaels_id_rsa"

  tags {
    Name = "test-instance"
  }

  volume_tags {
    Name = "test-instance"
  }
}

variable "vol_id" {}

resource "aws_volume_attachment" "test" {
  device_name = "/dev/xvdf"
  instance_id = "${aws_instance.test.id}"
  volume_id   = "${var.vol_id}"
}
  1. A root module referencing that file:
provider aws {
  region = "us-west-2"
}

resource "aws_ebs_volume" "test" {
  availability_zone = "us-west-2a"
  size              = "1"
  type              = "gp2"

  tags {
    Name = "test-vol"
  }
}

module "test" {
  source = "../../modules/bug"
  vol_id = "${aws_ebs_volume.test.id}"
}

Expected Behavior

The tag for aws_ebs_volume.test should consistently be "Name=>vol" according to the tags specified in that resource.

Actual Behavior

The "Name" tag switches back and forth between the value supplied by the aws_ebs_volume and the aws_instance.volume_tags.

Steps to Reproduce

After each subsequent terraform plan/apply, then I do aws --region us-west-2 ec2 describe-volumes --volume-ids "$volid" | jq -c '.Volumes[].Tags' using the volume id grabbed from the first run:

Run 1: [{"Value":"test-vol","Key":"Name"}]
Run 2: [{"Value":"test-instance","Key":"Name"}]

Important Factoids

This is so similar to #14107 I almost requested that be reopened, but when I tried to reproduce it in a very simple case without a non-root module, I couldn't. But when I put some components in a module, the problem was evident.

@icybin
Copy link

icybin commented May 24, 2017

I have the same issue . Thanks @kojiromike for you reporting.

@rmldsky
Copy link

rmldsky commented Jun 1, 2017

Hi,
Same problem on 0.9.6. Strange thing is that in one definition file I have created three instances the same way, three times aws_ebs_volume (with tags)/aws_volume_attachement/aws_instance(with volume_tags), and at the end I have problem only with 1/3 instance which constantly wants to change tags between volume_tags and tags (from aws_ebs_volume resource). Not sure if/how/what I can compare between those aws_instances to get some helpful output.

Also not sure if this issue relates to: #14019

@ghost
Copy link

ghost commented Mar 31, 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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Mar 31, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants