Terraform: [0.12] Taint of resource with count can't taint all items

Created on 29 May 2019  ยท  5Comments  ยท  Source: hashicorp/terraform

Before in 0.11 I could taint a resource with a count without having to know how many resources there was. Now when I do it need to use the new module reference syntax with [0] on the end to reference a single resource and can't use splat to get all.

Terraform Version

Terraform v0.12.0

Terraform Configuration Files

resource "aws_ebs_volume" "volume" {
  count             = 3
  availability_zone = element(var.azs, count.index)
  size              = var.disk_volume_size
  type              = var.volume_type
  encrypted         = var.encrypt_volume
  kms_key_id        = var.kms_key_id
  snapshot_id       = var.data_disk_snapshot_id
}

Expected Behavior

As in terraform 0.11
terraform taint -module=my-volume aws_ebs_volume.volume
And all of my volumes with counts would be tainted

Actual Behavior

Now with the new calling syntax it doesn't allow me taint a group of resources with counts

terraform taint module.my-volume.aws_ebs_volume.volume

Gives me an error saying "No resource instance"

terraform taint module.my-volume.aws_ebs_volume.volume[0]

Works but only for the 1st volume

terraform taint module.my-volume.aws_ebs_volume.volume[*]

Gives me an error saying "Splat expressions ([*]) may not be used here."

bug cli confirmed v0.12

Most helpful comment

I too depended on this functionality for tainting all of my replica databases when I rebuilt the master. It is nice if the engineer doing this doesn't have to know how many replicas we have. Everything else is just copy/paste.

All 5 comments

I too depended on this functionality for tainting all of my replica databases when I rebuilt the master. It is nice if the engineer doing this doesn't have to know how many replicas we have. Everything else is just copy/paste.

it affects to me as well.

it affects to me as well. I need to taint a for_each 's creations.

This issue is absolutely still valid, however I am closing it to consolidate it as a duplicate of https://github.com/hashicorp/terraform/issues/1768. taint, in its current form, operates on one resource instance at a time, and asking taint to target multiple resource instances at once is an enhancement (and a greatly valued one at that!) from current behavior.

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rnowosielski picture rnowosielski  ยท  3Comments

ketzacoatl picture ketzacoatl  ยท  3Comments

rjinski picture rjinski  ยท  3Comments

pawelsawicz picture pawelsawicz  ยท  3Comments

shanmugakarna picture shanmugakarna  ยท  3Comments