-
Notifications
You must be signed in to change notification settings - Fork 62
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
Inconsistent plan when introducing dependent object to output attribute while updating it #81
Comments
Yes this should be considered a bug. I've known about this error message for a while but I didn't know how to fix it. |
@rucciva Hi, i don't know if you still remember this, but it look like this PR added a bug - the simple case of updating any of the scripts (let's say i need to update for any reason) - it doesn't trigger the update itself.
Why? How should one trigger an update then? |
Hi @arielbeckjit , IIRC, you need to apply twice. The first apply should only update the "logic" of the script (lifecycle_commands, interpreter). The second apply will use the new logic against the other attributes and terraform state. And IIRC, i added conditions to prevent update of the logic part and other part at the same time. |
Hi @rucciva i've tested it and it doesn't work (applying twice). there's another big issue (atleast for me), is that i'm using sensitive_variables that have a temporary password that i'm using, so then if the temp password change, i cannot do changes in the script aswell (Because it clashes with this PR).
|
@rucciva i'll add why the double apply doesn't really work. to combat that, i need to manually do change in the env, so the state will be not aligned, then do another apply. |
This is what i mean by apply twice. In this PR, i made it so that change to the script "logic" (lifecycle_commands or interpreter IIRC) can't be done at the same time with changes to another attribute that is considered as "data" that will be processed by said "logic". So when you need to have updates to the logic part and the data part, you need to first update the logic part only, and then apply, and then update the data part, and then apply again. Its actually the same when you need to update a terraform provider version and the resources at the same time. Terraform will first update the provider version which will update the "logic" part, then it will use those new logic to read/create/update/delete the resource. So in the end, changes to "logic" should not be done at the same time with the "data". Or else it will produce inconsistent state as i pointed in this issue, which is what considered as a bug by terraform. |
What do you mean by "data" part? those are the environment variables for example? if so, then the behavior is expected indeed, though i'm not familiar with many resources that require double apply.. so - if i got you correct, the right logic is to:
|
Attributes other than lifecycle_commands and interpreter
Because terraform resources is normally only contains state, so data only. This provider meanwhile includes both data and logic on the state. The right steps when you need to change both the logic and the data part is
|
consider this initial resource
If we were to introduce dependent object which depend on the
output
value while at the same time updating the shell_script resource that affectoutput
value only after apply, it will produce inconsistent planThough this is error is retriable and next
terraform apply
will produce no issueThis is fixable if we invoke SetNewComputed whenever input changes or
read
commands change (and we also need to run theread
commands instead of not executing any commands when its updated). But this will always trigger recreation/update to dependent objects even tough after apply theoutput
was not modifiedWhat do you think? should this considered as bug?
The text was updated successfully, but these errors were encountered: