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
Fix terraform state in case of deployment error #4704
Conversation
Signed-off-by: Octavian Ionescu <itavyg@gmail.com>
hi @itavy Thanks for this PR. Terraform internally uses the Resource ID to be able to determine when resources have changed/deleted - in this instance we use the Resource ID to manage the Deployment assuming a valid ARM Template, as such any errors should be bubbled up to the user. If you're using Terraform to validate the ARM Templates (by deploying them) then you'll need to use Terraform's Taint functionality to force a recreation of this resource should the deployment fail. Whilst Terraform could automatically Taint the resource on error (which would Delete & then re-create it) - we intentionally don't do this within the Template Deployment resource since "Deleting" a Template Deployment doesn't do anything to the underlying resources. Unfortunately the solution proposed in this PR (untracking the resource in the case of a deployment error) will break when #2807 comes into effect in the near-future; as redeploying the resource (as if it were new) will show an error telling users to import the current Deployment into Terraform, unless it's deleted prior to the redeployment. Terraform currently makes the assumption that the ARM Template is valid at deployment time; assuming that users have run something like the Azure CLI's
We could instead change this to call the Thanks! |
@tombuildsstuff another approach will be to use partialUpdate in createUpdate method and update id inside that block, WDYT? |
@itavy taking a look into the SDK - it appears the
As such it should be possible to differentiate a Service Error (e.g. 500) and a Template Error (e.g.
Which I think means that Azure/azure-sdk-for-go#6125 is working as intended / it should be possible to do that approach - WDYT? Thanks! |
@tombuildsstuff ty for clarification. i didn't understood very well how they intend to use the sdk. i made another pull request taking in consideration your suggestions: #4715 |
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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 hashibot-feedback@hashicorp.com. Thanks! |
This solves the problem when you are trying to deploy a template and encounter an error related to validation;
The state in terraform is persisted with new values provided and subsequent runs will not detect a change
Signed-off-by: Octavian Ionescu itavyg@gmail.com