Terraform: Taint not finding resource within module

Created on 2 Mar 2017  ยท  5Comments  ยท  Source: hashicorp/terraform

Terraform Version

0.8.7

Debug Output

$ terraform state list |grep kong-ext.aws_instance
module.kong-ext.aws_instance.instance[0]
module.kong-ext.aws_instance.instance[1]

$ terraform taint -module='kong-ext' 'aws_instance.instance[0]'
The resource aws_instance.instance[0] couldn't be found in the module root.kong-ext.
$ terraform taint -module='kong-ext' 'aws_instance.instance'
The resource aws_instance.instance couldn't be found in the module root.kong-ext.

$ TF_LOG=TRACE terraform taint -module='kong-ext' 'aws_instance.instance' 
2017/03/02 12:43:32 [INFO] Terraform version: 0.8.7  c1df88ac4633b61b83802bbb10c343c20d3035b5
2017/03/02 12:43:32 [INFO] CLI args: []string{"/usr/local/bin/terraform", "taint", "-module=kong-ext", "aws_instance.instance"}
2017/03/02 12:43:32 [DEBUG] Detected home directory from env var: /Users/matt
2017/03/02 12:43:32 [DEBUG] Detected home directory from env var: /Users/matt
2017/03/02 12:43:32 [DEBUG] Attempting to open CLI config file: /Users/matt/.terraformrc
2017/03/02 12:43:32 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2017/03/02 12:43:32 [DEBUG] Detected home directory from env var: /Users/matt
2017/03/02 12:43:32 [TRACE] Preserving existing state lineage "146a8656-91ea-44e6-883f-804e713dbe6e"
2017/03/02 12:43:32 [TRACE] Preserving existing state lineage "146a8656-91ea-44e6-883f-804e713dbe6e"
2017/03/02 12:43:33 [TRACE] Preserving existing state lineage "146a8656-91ea-44e6-883f-804e713dbe6e"
2017/03/02 12:43:33 [TRACE] Preserving existing state lineage "146a8656-91ea-44e6-883f-804e713dbe6e"
2017/03/02 12:43:33 [TRACE] Preserving existing state lineage "146a8656-91ea-44e6-883f-804e713dbe6e"
2017/03/02 12:43:33 [TRACE] Preserving existing state lineage "146a8656-91ea-44e6-883f-804e713dbe6e"
2017/03/02 12:43:33 [DEBUG] plugin: waiting for all plugin processes to complete...

Expected Behavior

Terraform should be able to taint the resource from the module.

Actual Behavior

Terraform says the resource is not found despite the state showing them and otherwise behaving normally. State is remote via consul.

Most helpful comment

Hi @mattlqx,

Sorry about the confusion here, the output from the state command turns out to be a little differently formatted.

The taint command will use the format you see in the normal plan or apply output. The following example should give you want you want:

terraform taint -module='kong-ext' 'aws_instance.instance.0'

All 5 comments

Hi @mattlqx,

Sorry about the confusion here, the output from the state command turns out to be a little differently formatted.

The taint command will use the format you see in the normal plan or apply output. The following example should give you want you want:

terraform taint -module='kong-ext' 'aws_instance.instance.0'

Thanks for the reply. I thought that was one of the variations I tried too, but apparently I tried it while my state didn't have multiple instances in it. I did get it to work now. False alarm!

@jbardin how do you taint such magic stuff? module.rds_sharepass.db_instance.aws_db_instance.this

@holms,

The module would be specified like above, -module=rds_sharepass, but I'm not sure what db_instance.aws_db_instance.this is supposed to represent. What is that particular address from?

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

franklinwise picture franklinwise  ยท  3Comments

darron picture darron  ยท  3Comments

rjinski picture rjinski  ยท  3Comments

larstobi picture larstobi  ยท  3Comments

pawelsawicz picture pawelsawicz  ยท  3Comments