-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
Outputs populated from deposed resources #11716
Comments
Thanks. This is working as intended currently: because the full CBD fails, the resource itself never "completes" so the output is not updated. Put another way: the output's update depends on the successful completion of all resources it depends on. If the destroy or create fails in CBD, the completion failed, so the output isn't updated. I think we can do better here by constraining an output update to only the creation side of the CBD, though. |
Hi, thanks for the response. The thing is that this is currently inconsistent between the first and second update runs. Both attempt to destroy the deposed resource, and fail, but on the second run the output is updated, whereas on the first run, it isn't. At the moment we're able to work around the issue by running the update twice. |
I spent a little time thinking through what behavior I'd actually expect here. The most intuitive behavior would be for outputs to closely follow their dependencies: any time one of the dependency variables changes in the state, update the output immediately and flush both the resource update and the output update to persistent state at the same time. I think that result could be achieved without extensive surgery on the apply graph architecture: just make updating the outputs a side-effect of the A brute-force way to do it would be to just re-evaluate all of the outputs in the current module each time any resource state is updated. For all normal cases where the set of outputs is small I expect this would be sufficient. There are some degenerate cases: either having thousands of outputs, or having a single output that does an expensive operation such as reading a huge file from disk using |
Hi all! This one's been quiet for a while. I ended up bumping back into this old issue by accident while working on #21762; I sneaked up on it from a different angle because this time I visited the non- The apply walk often ends up having multiple nodes for the same resource that each make a different side-effect, but we only represent the named values (a collective term for local values, output values, and module input variables) by one node in the graph each, and thus the graph builder ends up trying to use those single nodes at multiple points in the walk. Because that's impossible, the actual result is either that the update happens too late (in the I left some more detailed notes in a comment on #21762 that describe what is essentially an evolution of my idea above: re-evaluating the named values constantly during the walk, each time their dependencies change. It'll take some more experimentation to see if that plan can translate from theory to practice, and it could be an invasive enough change that it'd need to wait for a future major release. We'll see! |
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. |
When updating an
aws_iam_server_certificate
that's in use (using create_before_destroy lifecycle), the output in the tfstate file continues to contain the value from the deposed version of the resource instead of the newly created version.Terraform Version
Affected Resource(s)
We're seeing this with an
aws_iam_server_certificate
resource, but I suspect this is not specific to this resource type.Terraform Configuration Files
Debug Output
Debug log from both update runs (described below) here: https://gist.github.com/alext/c7696a250f97a8ed6cebb4db6858b026
Actual Behavior
When running terraform to update the certificate, the new certificate is created, and the old one fails to be destroyed (this is expected because it's still in use), but the outputs in the tfstate file continue to contain the values from the old certificate.
A second run (which also fails to delete the deposed certificate) updates the outputs to contian the values for the new certificate.
Expected Behavior
The outputs should have been updated on the first terraform run when the new certificate was first created.
Steps to Reproduce
At this point the output in the tfstate file contains the ID of the deposed cert (
ASCAIBUB75J7JG3YJZNBK
in this example), and not the newly created one.At this point the tfstate file contains the correct ID in the output value.
The text was updated successfully, but these errors were encountered: