Hey everyone! I’ve been looking into Atmos couple...
# atmos
p
Hey everyone! I’ve been looking into Atmos couple of days now, and it looks really good for our use case. Something I am struggling with is how small I want my stacks to be split. We’re still relatively tiny SaaS company, but as we aim to be hosted on hyperscaler marketplaces, we probably need multi-cloud strategy (GCP being main one). We also do some consulting, and might host something outside of our core product, so I’ve utilized now “_namespace-tenant_” split, like in atmos docs. My name_template is currently:
"{{.vars.namespace}}-{{.vars.tenant}}-{{.vars.environment}}-{{.vars.stage}}-{{.vars.layer}}"
This leads to stack names such as:
Copy code
mp-plat-gcp-non-prod-meta
 mp-plat-gcp-non-prod-network
 mp-plat-gcp-non-prod-cluster
 mp-plat-gcp-shared-meta
So far in the environment I don’t have indication of Cloud region, only the vendor. Not sure if I should have it? Environments will be only “prod”/“non-prod” split, we’ll handle app specific staging, dynamic preview envs etc. with Argo-CD inside the clusters. I’m heavily utilizing Google’s excellent terraform modules for project creation, shared vpc and K8S cluster management. These are already on quite high level / opinionated, so components right now are really lightweight. I’ve split layers like this: • meta: things like org settings, folder creation and project creation ◦ why: my thinking is project creation should be split off from actual resource stacks, project rarely if at all changes after creation, and it can be slow to validate everything • network -> shared VPC stuff • cluster -> GKE cluster creation • clsuter-addons -> what necessary stuff goes into Kube cluster, like Argo-CD As to applications, I don’t know yet. We’ll probably aim to have multi-app clusters, apps could be deployed totally outside of Atmos as well. Definitely considering Argo-CD there, which I’ve had good experiences. Any feedback would be appreciated here! Am I having too small stacks?
I’ve not looked into Cloud Posse stuff at all, but once we must deploy on AWS and Azure, perhaps the same layered structure should function there.
I suppose any change to name_template later on, as the things change, is quite difficult to do? And this must be correct right from the start?
Claude Opus seems to think this structure is quite fine, but recommended to encode the region somewhere, and have two options. Option A — encode region in environment: Keep your template as-is but make environment more specific, like
gcp-euw1
instead of just
gcp
. This gives you
mp-plat-gcp-euw1-non-prod-network
. It’s a bit longer but unambiguous. Option B — add a dedicated region segment: Change the template to
{{.vars.namespace}}-{{.vars.tenant}}-{{.vars.environment}}-{{.vars.region}}-{{.vars.stage}}-{{.vars.layer}}
. This is cleaner semantically but adds another segment. Not sure if option B is too unwieldy, and some resources might be global anyway, like org folders. Of course I could then just encode it as “global”.
e
Ya those names are getting long… but at first glance looks good. I am going take a closer look later
We avoid using the delimiter in field so they are deterministic, but it's just guidance not a rule
You can also consider making namespace unique per cloud. E.g. mpa and mpg
We just pushed an update to https://atmos.tools/design-patterns/stack-organization/multi-cloud-configuration that clarifies some structural recommendations, but we still need to update the docs for name templates, which you are pointing out
p
@Erik Osterman (Cloud Posse) I realized actual state files that get created contain name of the component, in addition to anything I specify in stack name_template. Meaning, in layer named “cluster” I have probably just one component “gke”, or network layer has just one component named “network” 😄 A bit confusing. Maybe I should drop layered approach? Alternative might be that I split components much smaller, eg. network component splits into vpc creation, nat gateway etc. But this also sounds a bit ridiculous, spliting these things to separate tfstate files.
e
Our general guidance is not to make your components too small, because you don't want to try and recreate Terraform or HCL in YAML.
Our general recommendation is, when possible, to make components encapsulate what changes together. So, for example, the lifecycle of an account is very different from the lifecycle of a VPC, which is very different from the lifecycle of a cluster, which is very different from the lifecycle of the apps on the cluster.
So each one of those would typically be represented as a separate component.
p
@Erik Osterman (Cloud Posse) Do you generally recommend one component to create multiple instances, let’s say accounts or projects.. or clusters using for_each? Or each instance should be it’s own instance of the component, thus separate root state as well?
e
That's the factory pattern
We recommend putting the factory in atmos, keeping the components to manage one of a thing
We recently refactored our old monolithic AWS account componnent into a few separate ones: org, ou, and account
So I would consider that approach for GCP as well