Terraform-provider-aws: Terraform volume tags changes on alternate run if defined in both aws_instance and aws_ebs_volume resources

Created on 20 Aug 2018  路  12Comments  路  Source: hashicorp/terraform-provider-aws

_This issue was originally opened by @saveshnshetty as hashicorp/terraform#18713. It was migrated here as a result of the provider split. The original body of the issue is below._


Hi team,
I've defined volume tags in aws_instance resource and aws_ebs_volume resource since I need to add tags to root volume also. But when I ran "terraform apply" second time. Ebs volumes tags got replaced with aws instance volume tags. On third run it got replaced with original ebs volume tags .
This tags changes alternatively . Can you please look into it .

syntax :
resource "aws_instance" "app" {
count = "1"
ami = "${lookup(var.ami,var.region)}"
ebs_optimized = "${var.ebs_optimized}"
instance_type = "${var.instance_type_app}"
monitoring = "${var.monitoring}"
key_name = "${var.key_name}"
user_data = "${data.template_file.userdata-app..rendered[count.index]}"
network_interface {
network_interface_id = "${element(aws_network_interface.network-interface-app.
.id, count.index)}"
device_index = 0
}
tags {
Name = "$app-${count.index + 1}"
Type = "app"
Env = "${var.env}"
Customer_id = "${var.customer_id}"
}

    root_block_device {
        volume_type           = "${var.root_volume_type}"
        volume_size           = "${var.root_volume_size}"
        delete_on_termination = "${var.root_delete_on_termination}"
    }


    volume_tags {
        Name                  = "${var.env}-s4hana-app-${count.index + 1}"
        Type                  = "root-volume"
        Env                   = "${var.env}"
        Customer_id           = "${var.customer_id}"
    }

}

resource "aws_ebs_volume" "ebs-app" {
count = "${var.app_count}"
availability_zone = "**"
size = "${var.ebs_volume_size[0]}"
type = "${var.ebs_volume_type[0]}"
tags {
Name = "app-tmp"
Type = "ebs-volume"
Env = "${var.env}"
Customer_id = "${var.customer_id}"
}
}

bug servicec2

Most helpful comment

+1

All 12 comments

was seeing this also for a while.

similar issue with #5080

+1

we have a similar issue

I've also run into this issue.

Same issue. Is there any solution?

They don't actually change, so you can ignore it.

I can see this happening too
Terraform v0.12.8

  • provider.aws v2.31.0
    Ignoring this (as suggested above) is not good enough as the plan should stay clean if nothing is to be changed..

To add on to what @marobota said,

  • this is still occurring with aws provider 2.31.0
  • Contrary to what @Nklya stated, the tags are getting changed on my aws_ebs_volume resources
  • I am also seeing only one of my 5 defined tags being applied to the root volume.

Something definitely isn't right.

This is still happening.

```
An execution plan has been generated and is shown below.

Resource actions are indicated with the following symbols:
~ update in-place

Terraform will perform the following actions:

~ aws_instance.google-prod-app
volume_tags.Name: "google-prod-app-001:/root" => "google-prod-app-001"

Plan: 0 to add, 1 to change, 0 to destroy.


Note: You didn't specify an "-out" parameter to save this plan, so Terraform
can't guarantee that exactly these actions will be performed if
"terraform apply" is subsequently run.
```

There is a workaround:
Remove volume_tags from your aws_instance and add the following aws_ec2_tag:

resource "aws_ec2_tag" "root_volume_tags" {
  resource_id = aws_instance.this.root_block_device[0].volume_id
  key         = "Name"
  value       = "VALUE"
}  

Are there any plans to address this? I am also seeing this issue

Was this page helpful?
0 / 5 - 0 ratings