boltops-tools / terraspace

Terraspace: The Terraform Framework
https://terraspace.cloud
Apache License 2.0
674 stars 46 forks source link

Retry output values from state before defaulting to mock value #300

Open exoaturner opened 1 year ago

exoaturner commented 1 year ago

Summary

This may be a bug but I have been unable to prove its terraspace at fault. However, this could improve the stability of using mocks and how it could potential impact projects.

On occasion under unknown conditions when a stack is getting a value from another stack the output() function doesn't find the value in the state and reverts to using the mock value. This can occur even if it found it in a previous plan. This seems to be random and maybe related to things outside of terraspace (for example when using aws s3 as a backend).

Motivation

Improve the redundancy of using terraspace all up, when using the output() function. what I found is if the output was used as a key for a resource the resource would be deleted unexpectedly because the plan didn't reflect that change.

Guide-level explanation

Option 1: The terraspace output() helper function has the ability to retry if it doesn't find output in the state.

or

Option 2: Terraspace has an option to fail a deploy if it detects a mock in the compiled terraform code.

Reference-level explanation

n/a

Drawbacks

Option 1: Could potentially slow down if it need to retry finding the value in the state file multiple times. However, maybe the number of retries could be configurable before defaulting to the mock.

Option 2: No drawbacks if its toggleable.

Unresolved Questions

n/a

exoaturner commented 1 year ago

@tongueroo apologies if this is in the wrong place. I felt this was more of a feature request/improvement then a bug on the terraspace side.