Attempting to taint a single resource from a list of resources errors with Error: Attribute name required
v0.12.0-dev (compiled from master today)
resource "test_resource" "multiple" {
count = 2
required = "foo"
required_map = {
foo = "bar"
}
}
terraform taint test_resource.multiple.1
The resource test_resource.multiple.1 in the module root has been marked as tainted!
terraform taint test_resource.multiple.1
Error: Attribute name required
on line 1:
(source code not available)
Dot must be followed by attribute name.
terraform initterraform applyterraform taint test_resource.multiple.1
terraform 0.11.10 works
Hi @sjwl,
Thanks for pointing this out.
The address syntax in 0.12 has been made more consistent, and indexing is now always done with the [] index operator. The proper syntax for this command would be
terraform taint test_resource.multiple[1]
I'll see if we can point this out a little better in the cli or the docs.
@jbardin interesting...here's what I get
terraform taint test_resource.multiple[1]
zsh: no matches found: test_resource.multiple[1]
But this error doesn't seem to be from terraform, so I wrap the resource in quotes
terraform taint "test_resource.multiple[1]"
Resource instance test_resource.multiple[1] has been marked as tainted.
this helped me find a better workaround with the zsh error:
https://thoughtbot.com/blog/how-to-use-arguments-in-a-rake-task
added to my .zshrc
unsetopt nomatch
Ah yes, the square brackets take precedence in zsh. In bash it's not a factor, but it's usually good practice to properly quote arguments to prevent misinterpreting them.
How to taint all indexes in resource?
Let say I want taint
aws_instance.bar[*]
Is it posible?
I'm on Terraform v0.12.26 and have hit this with string indexes. I am definitely passing through the correct syntax, but TF is refusing to understand it's a string:
> echo azurerm_key_vault_secret.organization_google_credentials["something"]
azurerm_key_vault_secret.organization_google_credentials["something"]
> terraform untaint azurerm_key_vault_secret.organization_google_credentials["something"]
Error: Index value required
on line 1:
(source code not available)
Index brackets must contain either a literal number or a literal string.
Any help appreciated!
Hi @kentcb
If you haven't got a solution to this already, I think you need to escape the double quotes per here: https://www.terraform.io/docs/commands/taint.html#example-tainting-a-single-resource-created-with-for_each
I am going to close this issue due to inactivity; it seems the questions in here have been answered and there is not a bug.
If there is still a question, I recommend the the community forum, where there are far more people available to help. If there is a bug or you would like to make a feature request, please open a new issue and fill out the template.
Thanks!
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.
Most helpful comment
this helped me find a better workaround with the
zsherror:https://thoughtbot.com/blog/how-to-use-arguments-in-a-rake-task
added to my
.zshrc