Repository navigation
Add atmos describe dependants command. Update docs - #339
Conversation
… level in the `components/terraform` and `components/helmfile` folders
|
when running : the output order is in the order of dependency? I do not know if the order of execution could be an easy output to add |
Matt Calhoun (mcalhoun)
left a comment
There was a problem hiding this comment.
Overall this looks good...I made a couple of small comments/requests.
In For example, below we specify that the components:
terraform:
eks:
settings:
depends_on:
1:
component: vpccomponents:
terraform:
rds:
settings:
depends_on:
1:
component: vpcThen, we provision (or update) the atmos terraform apply vpc -s <stack>Then we want to know what components depend on the atmos describe dependants vpc -s <stack>We get back the following: [
{
"component": "eks",
"component_type": "terraform",
"stack": "....",
"stack_slug": "....",
"atlantis_project": "...."
},
{
"component": "rds",
"component_type": "terraform",
"stack": "....",
"stack_slug": "....",
"spacelift_stack": "....",
"atlantis_project": "...."
}
]Then we trigger the dependent components to check if they need to be updated after the atmos terraform plan eks -s <stack>
atmos terraform plan eks -s <stack>After that you can run commands atmos describe dependants eks -s <stack>
atmos describe dependants rds -s <stack>to see if those components have dependencies that need to be run. |
Thanks Andriy Knysh (@aknysh) that makes sense. |
what
components/terraformfolder deeper than the second levelatmos describe dependantscommandwhy
Fix an issue when the terraform components were in subfolders in the
components/terraformfolder deeper than second level. For example:The component
test-component-2is in the subfoldercomponents/terraform/test/test2, for which the filesystem path to the generatedvarfilewas created incorrectly (when used justcomponents/terraform/testsubfolder, it was correct). The PR fixes the issue, and now components can be in any subfolder at any level.The
atmos describe dependantscommand produces a list of Atmos components in Atmos stacks that depend on the provided Atmos componentdescription
In Atmos, you can define component dependencies by using the
settings.depends_onsection. The section used to define all the Atmos components (in the same or different stacks) that the current component depends on.The
settings.depends_onsection is a map of objects. The map keys are just the descriptions of dependencies and can be strings or numbers. Provide meaningful descriptions so that people can understand what the dependencies are about.Each object in the
settings.depends_onsection has the following schema:component(required) - an Atmos component that the current component depends onnamespace(optional) - thenamespacewhere the Atmos component is provisionedtenant(optional) - thetenantwhere the Atmos component is provisionedenvironment(optional) - theenvironmentwhere the Atmos component is provisionedstage(optional) - thestagewhere the Atmos component is provisionedThe
componentattribute is required. The rest are the context variables and are used to define Atmos stacks other than the current stack. For example, you can specify:namespaceif thecomponentis from a different Organizationtenantif thecomponentis from a different Organizational Unitenvironmentif thecomponentis from a different regionstageif thecomponentis from a different accounttenant,environmentandstageif the component is from a different Atmos stack (e.g.tenant1-ue2-dev)In the following example, we define that the
top-level-component1component depends on the following:test/test-component-overridecomponent in the same Atmos stacktest/test-componentcomponent in Atmos stacks identified by thedevstagemy-componentcomponent from thetenant1-ue2-stagingAtmos stackIn the following example, we specify that the
top-level-component2component depends on the following:test/test-componentcomponent in the same Atmos stacktest/test2/test-component-2component in the same Atmos stackHaving the
top-level-componentandtop-level-component2components configured as shown above, we can now execute the following Atmos command to show all the components and stacks that are dependants of thetest/test-componentcomponent in thetenant1-ue2-devstack:[ { "component": "top-level-component1", "component_type": "terraform", "component_path": "examples/complete/components/terraform/top-level-component1", "namespace": "cp", "tenant": "tenant1", "environment": "ue2", "stage": "dev", "stack": "tenant1-ue2-dev", "spacelift_stack": "tenant1-ue2-dev-top-level-component1", "atlantis_project": "tenant1-ue2-dev-top-level-component1" } ]Similarly, the following Atmos command shows all the components and stacks that are dependants of the
test/test-componentcomponent in thetenant1-ue2-test-1stack:[ { "component": "top-level-component1", "component_type": "terraform", "component_path": "examples/complete/components/terraform/top-level-component1", "namespace": "cp", "tenant": "tenant1", "environment": "ue2", "stage": "test-1", "stack": "tenant1-ue2-test-1", "spacelift_stack": "tenant1-ue2-test-1-top-level-component1", "atlantis_project": "tenant1-ue2-test-1-top-level-component1" }, { "component": "top-level-component2", "component_type": "terraform", "component_path": "examples/complete/components/terraform/top-level-component1", "namespace": "cp", "tenant": "tenant1", "environment": "ue2", "stage": "test-1", "stack": "tenant1-ue2-test-1", "atlantis_project": "tenant1-ue2-test-1-top-level-component2" } ]After the
test/test-componenthas been provisioned, you can use the outputs to perform the following actions:Provision the dependent components by executing the Atmos commands
atmos terraform apply top-level-component1 -s tenant1-ue2-test-1andatmos terraform apply top-level-component2 -s tenant1-ue2-test-1(on the command line or from a GitHub Action)Trigger the dependent Spacelift stack (from a GitHub Action by using the spacectl CLI, or by using an OPA Trigger policy, or by using the spacelift_stack_dependency resource)
Trigger the dependent Atlantis project
related