-
Notifications
You must be signed in to change notification settings - Fork 9.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
terraform state rm always displays success message as long as you give it a "valid" resource name #17800
Comments
You can also replicate this by trying to remove the same item over and over again:
This also becomes a problem when accidentally mistyping a resource name that doesn't exist, and not realising:
|
Furthermore,
The full |
Seen this also with Terraform v0.11.10 |
The output was corrected. I'm using $ terraform state rm module.that.aws_ecs_task_definition.this_non_created_resource
Acquiring state lock. This may take a few moments...
No matching resource instances found.
Releasing state lock. This may take a few moments...
$ echo $?
0 Should the exit code be in the scope of this bug? $ terraform state show module.that.aws_ecs_task_definition.this_non_created_resource
No instance found for the given address!
This command requires that the address references one specific instance.
To view the available instances, use "terraform state list". Please modify
the address to reference a specific instance.
$ echo $?
1 |
Commands `state rm` and `state mv` will now exit with code 1 when the target resource is not found in the current state. This is consistent with `terraform state show non_existent_resource`. Fixes hashicorp#17800
* command: adjust exit code of state rm and state mv Commands `state rm` and `state mv` will now exit with code 1 when the target resource is not found in the current state. This is consistent with `terraform state show non_existent_resource`. Fixes #17800
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. |
Terraform Version
Terraform Command
Expected Behavior
Terraform should give me an error saying the resource does not exist.
Actual Behavior
Terraform says it removed 1 item successfully.
Steps to Reproduce
In any folder, even one that does not contain state run
terraform state rm random_type.random_name
. If there's no.
Terraform will complain:but beyond that it always prints the success message.
The text was updated successfully, but these errors were encountered: