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 wants to remove tags from aws_attached_volume volumes #14019

Closed
emk opened this issue Apr 26, 2017 · 2 comments
Closed

Comments

@emk
Copy link

emk commented Apr 26, 2017

Terraform Version

Terraform v0.9.4

Affected Resource(s)

Please list the resources as a list, for example:

  • aws_instance
  • aws_volume_attachment
  • aws_ebs_volume

Terraform Configuration Files

resource "aws_instance" "mydb" {
  ami = "..."
  instance_type = "..."
  availability_zone = "..."

  vpc_security_group_ids = ["..."]

  root_block_device {
    volume_type = "gp2"
    volume_size = 30
  }
}

resource "aws_ebs_volume" "mydb_data" {
  availability_zone = "..."
  size = "10"
  type = "gp2"
  tags {
    Name = "mydb:/data"
  }
}

resource "aws_volume_attachment" "mydb_data" {
  device_name = "/dev/sdh"
  volume_id = "${aws_ebs_volume.mydb_data.id}"
  instance_id = "${aws_instance.mydb.id}"

  connection {
    host = "${aws_instance.mydb.public_ip}"
    user = "ec2-user"
    private_key = "..."
  }

  # Run a script to mount this volume as '/data'.
  provisioner "remote-exec" {
    scripts = [
      "${path.module}/scripts/mount-ebs-data-volume.sh"
    ]
  }
}

Debug Output

We can supply this if this proves difficult to reproduce, but we'll need to strip out proprietary data.

Panic Output

None.

Expected Behavior

Terraform should leave the Name of the volume alone, and not try to remove it.

Actual Behavior

The plan always includes:

~ aws_instance.mydb
    volume_tags.%:    "1" => "0"
    volume_tags.Name: "mydb:/data" => ""

If run, this will strip the Name off our volume.

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. terraform apply

Important Factoids

We use a lot of aws_volume_attachment declarations.

References

None.

Workaround

It appears possible to fix/improve this by adding:

  lifecycle {
    # Don't allow Terraform to update volume tags, because if it does, it will
    # erase tags on volumes attached by aws_volume_attachment.
    ignore_changes = ["volume_tags"]
  }

...to each affected instance.

@stack72
Copy link
Contributor

stack72 commented Apr 27, 2017

Hi @emk

I just fixed this this afternoon in master - it will be released in Terraform 0.9.5 which i will try and ship soon!

Sorry for the issue

Paul

@ghost
Copy link

ghost commented Apr 13, 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 Apr 13, 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

2 participants