terraform state: how do you show an instance with a count?

Say we have an instance which has been built with a count.

After downloading the JSON state file from S3 (assuming you’re hosting it remotely) then you can look in the state file for this resource using:

terraform show ~/Downloads/terraform-state-file.json | less

Assuming it’s called my-instance¬†you can search for it and you’ll find:

aws_instance.my-instance.0:

and

aws_instance.my-instance.1:

etc.

So, let’s say you want to taint this resource. Let’s try show¬†initially on it as it’s non-destructive so:

tf state show aws_instance.my-instance.0

But this gives:

Error filtering state: Error parsing address ‘aws_instance.my-instance.0’: Unexpected value for InstanceType field: “0”

Please ensure that all your addresses are formatted properly.

Using my-instance[0]does not work.

 

You need to specify the instance using:

//TODO

 

Leave a Reply

Your email address will not be published. Required fields are marked *