Can't seem to taint a instance of a resource

I’m trying to taint an instance of a resource and when I try it says it can’t find the resource in the state file
In this case if I run the command Terraform state list I see the resource in the list azurerm_automation_schedule.custom_sunday[“1”]
If I then try the command Terraform state show azurerm_automation_schedule.custom_sunday[“1”] I get the error No instance found for the given address!

it is in the state file, here is a picture of it

image

Any idea why I can list it, but not show it or taint it?

I’m guessing your shell is eating the double-quote characters when you give the resource address on the command line.

You should use simple quotes for the terraform resource id like this:

terraform state show 'azurerm_automation_schedule.custom_sunday[“1”]'

Thought the shell as well could be the case as well but I’ve tried it in the wsl environment and I get the same issue :frowning: .

Might log a official support ticket as this seems odd

(sorry for the late reply maxb, typed out the question but did hit the reply button, doh)

Tried the simple qoutes but no joy as well

I’m guessing from your mention of WSL that you are using Windows. Unfortunately the treatment of quotes in the command line is a bit more annoying in Windows, particularly if you are using PowerShell since PowerShell’s handling of command lines for external programs (rather than its own cmdlets) is quirky.

To make it work on Windows I would suggest:

  • Use the Command Prompt with cmd.exe instead of PowerShell, because its command line parsing is more predictable than PowerShell’s.

  • Use backslashes to escape the quotes, since that’s the convention on Windows:

    terraform state show azurerm_automation_schedule.custom_sunday[\"1\"]
    

The single quotes ' is a convention for Unix shells, and isn’t typically supported by Windows applications, including the Windows build of Terraform.

Thanks guys, after testing the examples I can confirm
terraform state show ‘azurerm_automation_schedule.custom_sunday[\“1\”]’ works in powershell on a windows base machine
terraform state show ‘azurerm_automation_schedule.custom_sunday[“1”]’ works in WSL on a windows based machine