Terraform enables you to safely and predictably create, change, and improve infrastructure. It is a source-available tool that codifies APIs into declarative configuration files that can be shared amongst team members, treated as code, edited, reviewed, and versioned.
No additional output with trace debugging enabled.
Expected Behavior
Resource to be removed from state
Actual Behavior
Syntax error or failure to find existing resource within state
Steps to Reproduce
Attempt to remove existing resource from state where the address contains a name.
The following command permutations (amongst others) were executed in desperate attempt to successfully remove an item.
Command:
terraform state rm module.module_name.resource_type.resource_address["name"]
Result:
│ Error: Index value required
│
│ on line 1:
│ (source code not available)
│
│ Index brackets must contain either a literal number or a literal string.
Command:
terraform state rm module.module_name.resource_type.resource_address[\"name\"]
Result:
│ Error: Invalid target address
│
│ No matching objects found. To view the available instances, use "terraform state list". Please modify the address to
│ reference a specific instance.
Command:
terraform state rm 'module.module_name.resource_type.resource_address[\"name\"]'
Result:
│ Error: Invalid character
│
│ on line 1:
│ (source code not available)
│
│ Single quotes are not valid. Use double quotes (") to enclose strings.
│ Error: Variable name required
│
│ on line 1:
│ (source code not available)
│
│ Must begin with a variable name.
Command:
terraform state rm "module.module_name.resource_type.resource_address[\"name\"]"
Result:
│ Error: Invalid target address
│
│ No matching objects found. To view the available instances, use "terraform state list". Please modify the address to
│ reference a specific instance.
Additional Context
Suggestions within Referred to seem to no longer be valid.
Closed since I realised I was working in a different workspace to one which I thought I was.
Why the light sometimes only seems to since only after creating an issue!
Terraform Version
Terraform Configuration Files
Debug Output
No additional output with trace debugging enabled.
Expected Behavior
Resource to be removed from state
Actual Behavior
Syntax error or failure to find existing resource within state
Steps to Reproduce
Attempt to remove existing resource from state where the address contains a name. The following command permutations (amongst others) were executed in desperate attempt to successfully remove an item.
Command:
terraform state rm module.module_name.resource_type.resource_address["name"]
Result: │ Error: Index value required │ │ on line 1: │ (source code not available) │ │ Index brackets must contain either a literal number or a literal string.
Command:
terraform state rm module.module_name.resource_type.resource_address[\"name\"]
Result: │ Error: Invalid target address │ │ No matching objects found. To view the available instances, use "terraform state list". Please modify the address to │ reference a specific instance.
Command:
terraform state rm 'module.module_name.resource_type.resource_address[\"name\"]'
Result: │ Error: Invalid character │ │ on line 1: │ (source code not available) │ │ Single quotes are not valid. Use double quotes (") to enclose strings.
│ Error: Variable name required │ │ on line 1: │ (source code not available) │ │ Must begin with a variable name.
Command:
terraform state rm "module.module_name.resource_type.resource_address[\"name\"]"
Result: │ Error: Invalid target address │ │ No matching objects found. To view the available instances, use "terraform state list". Please modify the address to │ reference a specific instance.
Additional Context
Suggestions within Referred to seem to no longer be valid.
References
24990