Skip to content

Module updates attached volumes even with ignore tags #433

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

Open
1 task done
argeljoseph opened this issue May 26, 2025 · 3 comments
Open
1 task done

Module updates attached volumes even with ignore tags #433

argeljoseph opened this issue May 26, 2025 · 3 comments

Comments

@argeljoseph
Copy link

argeljoseph commented May 26, 2025

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.

  • ✋ 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
Copy link
Author

argeljoseph commented May 26, 2025

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

@jebbens
Copy link
Contributor

jebbens commented May 27, 2025

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.

@bryantbiggs
Copy link
Member

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 hashicorp/terraform-provider-aws#21806 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants