-
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
show deprecation warning if -state
is used in conjunction with plan
or apply
#35562
Comments
Hi @EugenKon, That is definitely not the typical behavior here, and I'm not sure how you've managed to get resources which are not causing Terraform to initialize a provider. Even if you had configured providers within the module then removed them, which would cause an error because the provider config is not persisted, it would be a different error from this. Can you show the output of Thanks! |
@jbardin Yes, sure. This is how it looks on upgraded cluster:
This is before downgrade (a cluster with configuration without tls_private_key and random_uuid resources:
Plan
After adding required providers into providers.tf
I ran plan again:
After plan was applied here is output for already the downgraded cluster (I mean the cluster without tls and random resources at the configuration):
*PS. By the way, could it be possible to hide generated secret for
I can not find anything related to this here: https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/uuid |
Thanks for all the extra info @EugenKon! I'm guessing that it has something to do with the (Also, there's unfortunately not any way to hide normal resource plan data from the output right now, unless that provider declares the attributes as |
So I've managed to get a slightly different error, but I still think this is caused by the legacy Does terraform work correctly if you configure the local backend to point to the state file?
|
@jbardin The give configuration resolves the problem also. It works as expected: no error messages about 'tls' and 'random' providers. I hope my feedback helped you. Thanks. |
Thanks @EugenKon. Since the |
@jbardin It would be nice to warn about No deprecation warning for |
That's a good point, it is deprecated in the documentation, but perhaps we could add a message if it's used in conjunction with |
-state
is used in conjunction with plan
or apply
Hi @jbardin, can I work on this one? |
Hi @melsonic, please read https://github.com/hashicorp/terraform/blob/main/.github/CONTRIBUTING.md. Particularly the "Proposing a Change" section. Thanks! |
Hi @crw, I have been through the codebase and found the following information
Let me know if I missed some point, or I can proceed with the implementation. |
Thanks for the proposal, I will raise it in triage! |
sure, thanks @crw |
Hi @melsonic, I'm happy to review a PR for this if you raise one 👍 The It is actually only included in this way through plan.go, apply.go, and refresh.go which luckily are all the commands we want to add the warning for. My approach would be to update the extendedFlagSet function so that it returns diagnostics alongside the initialised flags, and these diagnostics could include a warning about the state flag being deprecated. Alternatively, we could avoid editing the shared function, and update the call sites so they check if the Hopefully that makes sense, and I'll leave it up to you if you want to take either of those approaches. |
Hey @liamcervante , thanks for your input. I will start working on this and submit a PR. |
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. |
Terraform Version
Debug Output
Expected Behavior
Terraform should load providers automatically for resources to delete them as it done for the same resources to create them.
Actual Behavior
I need to configure providers explicitly to delete resources not in configuration but in a state.
Steps to Reproduce
I assume, that terraform should connect tls and random providers automatically for resource delation as it was done to create these resources. For the first case, when resources are created, this is done from the information in a configuration. For the second case, when resources should be deleted, this could be done from the information in a terrafomr.tfstate file.
Additional Context
Because for the first case terraform core loaded tls and random providers automatically, I decided that the same should be done by terraform core for the second case. Thus this does not belongs to 'terraform-provider-tls' and/or 'terraform-provider-random'.
References
No response
The text was updated successfully, but these errors were encountered: