terraform-aws-ec2-instance icon indicating copy to clipboard operation
terraform-aws-ec2-instance copied to clipboard

Module updates attached volumes even with ignore tags

Open argeljoseph opened this issue 6 months ago β€’ 3 comments

Using this module while adding and attaching ebs volume resource separately...

I added an aws_ebs_volume, and aws_volume_attachment that works in conjunction with this module. I manage the tags as well on the ebs_volume (separate from the module tags... However, once an EC2 instance is built (with the EBS volumes attached, and tags managed separately) The module tries to update the name of a managed volume (that it doesn't manage

If your request is for a new feature, please use the Feature request template.

  • [x] βœ‹ I have searched the open/closed issues and my issue is not listed.

⚠️ Note

Before you submit an issue, please perform the following first:

  1. Remove the local .terraform directory (! ONLY if state is stored remotely, which hopefully you are following that best practice!): rm -rf .terraform/
  2. Re-initialize the project root to pull down modules: terraform init
  3. Re-attempt your terraform plan or apply and check if the issue still persists

Versions

  • Module version [Required]: 5.8.0

  • Terraform version: 1.12

  • Provider version(s): aws 5.94.1

Reproduction Code [Required]

Steps to reproduce the behavior:

Using TF workspace

Expected behavior

It will not update the tags of the EBS volumes

Actual behavior

It's updating the EBS volumes

Image

argeljoseph avatar May 26 '25 12:05 argeljoseph

resource "aws_ebs_volume" "ec2_volumes" {
  for_each = {
    for disk in local.info_disk_object : "${disk.ec2_key}.${disk.disk_key}" => disk
  }

  provider = aws.syd

  type              = each.value.type == "" ? "gp3" : each.value.type
  iops              = each.value.iops == null ? 3000 : each.value.iops
  throughput        = each.value.throughput == null ? 125 : each.value.throughput
  availability_zone = "${var.regions[each.value.region]}${var.aws_ec2s[each.value.ec2_key].availability_zone}"
  size              = each.value.size == null ? 64 : each.value.size
  snapshot_id       = each.value.snapshot_id
  encrypted         = each.value.encrypted
  kms_key_id        = each.value.kms_key_id == "" ? local.kms_defaults.syd_ebs : each.value.kms_key_id
  tags              = merge(local.common_tags, { Name = "${each.value.ec2_key}${each.value.disk_key}" })
  lifecycle {
    ignore_changes = [
      tags,
    ]
  }

So, I'm doing something like this so that the ebs volumes I attach can be customised... I'm using for_each as in my ec2 module, I'm using diffrent type of VMs too with varying sizes of attached EBS volumes... It hink the version 4.5 "broke" this as I can see in the changes that the volume tags handling was added there.

Is there a way for me to ignore that ebs related handling of tags by the module? or at least for the module to not "bypass" the lifecycle block of ignoring tags? @jebbens

argeljoseph avatar May 26 '25 23:05 argeljoseph

I'm not super familiar with this module - I made one small commit years ago - but, did you try adding the volumes using the ebs_block_device variable? It looks like there shouldn't be any limits to customization using that approach.

jebbens avatar May 27 '25 12:05 jebbens

in conjunction with #433 - we probably need to refactor the module to not use the inline ebs_block_device and instead switch to aws_ebs_volume and aws_volume_attachment resources as shown here https://github.com/hashicorp/terraform-provider-aws/issues/21806#issuecomment-1175539864

bryantbiggs avatar Jun 04 '25 22:06 bryantbiggs

This issue has been resolved in version 6.0.0 :tada:

antonbabenko avatar Jun 24 '25 19:06 antonbabenko

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.

github-actions[bot] avatar Jul 25 '25 02:07 github-actions[bot]