terraform state show for items with count

Viewed 518

When I have an instance that's been generated with count I am unable to see the state using:

terraform state show instance-name.0

If I use:

terraform state show instance-name[0]

that doesn't work either.

How do you show the state of an instance that has been built with count?

3 Answers

It is indeed a character escaping issue. Square brackets really are reserved in bash, so adding single-quotes to the resource name did the trick. The command will become something like: terraform state show 'azurerm_network_interface.web_server_nic[1]'

it should work with the square brackets. If you do terraform state list you should see the resources you can show. Should be able to append this to terraform state show, e.g terraform state show azurerm_network_interface.web_server_nic[1]

Perhaps it is a quoting/escaping issue? Aren't square brackets a reserved character in bash? Poor answer maybe, but did you try it with single quotes around the resource address?

Related