Open MReggler opened 6 months ago
This is essentially the risk with using the try(coalesce(<option_a>,<option_b>), <default>)
pattern without unit tests, any unforeseen error in the internal coalesce is masked to the default value, which is valid Terraform
Describe the Bug
After updating the component to 1.400.0 from a prior version, all stacks are moved to the
root
Spacelift space, unless the new optional Spacelift settings keywordspace_name_pattern
is defined in every stack.Why this is happening
The change to calculation space_id in the
child-stacks.tf
andspaces.tf
involves a guard condition that presupposes the existence of a new keyspace_name_pattern
. Excerpt of the new logic that appears in both files is included below:The condition checking that
each.value.settings.spacelift.space_name_pattern
does not equal the empty string or null requires that key to exist. As all of the logic in this block occurs within a Terraformtry()
function, every component is mapped to the default string "root".The value
settings.spacelift.space_name_pattern
key is intended to be optional, but is not optional in practice.If you remove the
try()
statement, the hidden error appearsExpected Behavior
For an Atmos component definition, if the spacelift settings key
space_name
key has been defined, and the newspace_name_pattern
key has not been defined, then the resultant stack should be assigned to the named space in SpaceliftSteps to Reproduce
space_name
key under "settings.spacelift". Do not set thespace_name_pattern
key.atmos terraform plan spacelift/admin-stack -s example-spacelift-gbl
You will notice the the Spacelift stacks created for the "child components" of this administrative stack will be created in the
root
space, not theexample
space as defined in the above configuration.Screenshots
No response
Environment
No response
Additional Context
No response