- Move
atmos.yamlconfig file to~/.atmos/atmos.yaml - Set
ATMOS_BASE_PATHto repo rootexport ATMOS_BASE_PATH=$(pwd)
- Apply spaces with
atmos terraform apply spaces -s root-gbl-spacelift
Apply complete! Resources: 9 added, 0 changed, 0 destroyed.
Policies + Spaces created in spacelfit successfuly (plat and core)
- Apply root admin stack
atmos terraform apply admin-stack -s root-gbl-spacelift
Fails at plan:
Could not find the component 'spacelift/spaces' in the stack 'root-gbl-root'. │ Check that all the context variables are correctly defined in the stack manifests. │ Are the component and stack names correct? Did you forget an import? │ │ with module.spaces.data.utils_component_config.config[0], │ on .terraform/modules/spaces/modules/remote-state/main.tf line 1, in data "utils_component_config" "config": │ 1: data "utils_component_config" "config" { │
-
Change the
spacelift_spaces_stage_namefromroottospaceliftin thestacks/catalog/spacelift/admin-stack.yamlsolves the problem of looking for the component in the wrong stackroot-gbl-root -
Rename the atmos component of the spacelift spaces from
spacestospacelift/spacesinstacks/catalog/spacelift/spaces.yaml. To solve the error that the componentspacelift/spacesdoesn't exists.
2.1. Trying to apply the root admin stack again after applying both fixes:
Fails at plan:
╷ │ Error: Invalid index │ │ on root-admin-stack.tf line 108, in resource "spacelift_policy_attachment" "root": │ 108: policy_id = local.policies[each.key] │ ├──────────────── │ │ each.key is "TRIGGER Global administrator" │ │ local.policies is object with 7 attributes │ │ The given key does not identify an element in this collection value. ╵
- Replace the
root_stack_policy_attachmentsinorgs/acme/spacelift.yamlfrom[TRIGGER Global administrator]to[](empty array)
2.2. Run the apply of the admin stack again
Apply complete! Resources: 27 added, 0 changed, 0 destroyed.
Following stacks where created in spacelift:
- root-gbl-spacelift-admin-stack
- root-gbl-spacelift-spacelift-spaces
- core-gbl-spacelift-admin-stack
- plat-gbl-spacelift-admin-stack
- Apply tenant-specific spaces
atmos terraform apply admin-stack -s core-gbl-spacelift
Fails at plan:
╷ │ Error: │ Could not find the component 'spacelift/spaces' in the stack 'core-gbl-spacelift'. │ Check that all the context variables are correctly defined in the stack manifests. │ Are the component and stack names correct? Did you forget an import? │ │ │ with module.spaces.data.utils_component_config.config[0], │ on .terraform/modules/spaces/modules/remote-state/main.tf line 1, in data "utils_component_config" "config": │ 1: data "utils_component_config" "config" { │
- Add the import to the tenant-specific of the spaces component
catalog/spacelift/spaces
Fails at apply time:
╷ │ Error: could not create stack: could not persist the stack: stack/module with this slug already exists for this account │ │ with module.child_stack["core-gbl-spacelift-admin-stack"].spacelift_stack.this[0], │ on .terraform/modules/child_stack/modules/spacelift-stack/main.tf line 18, in resource "spacelift_stack" "this": │ 18: resource "spacelift_stack" "this" { │
... To be continued ...