Question, I have two competing components overwrit...
# atmos
j
Question, I have two competing components overwriting the backend.json file in the same directory. How do I ensure each component (each used a common root module/abstract component), uses a unique backend.json (e.g. prefix the backend.json with the stack name)
a
Atmos handles that automatically by generating the workspaces for multiple component instances https://atmos.tools/design-patterns/multiple-component-instances/ https://atmos.tools/core-concepts/components/terraform/workspaces/
Copy code
Atmos computes the workspace name to be ue2-dev. Any Atmos Terraform command other than init, using this stack, will cause Atmos to select this workspace, creating it if needed.

The exception to the default rule (using the stack name as Terraform workspace) is when we provision more than one instance of the same Terraform component (with the same or different settings) into the same stack by defining multiple Atmos components. In this case, Atmos calculates the Terraform workspace for each component by joining the stack name with the component name.

Atmos computes the workspace names as ue2-dev-vpc-1 and ue2-dev-vpc-2 respectively, and selects the appropriate workspace for each component (again, creating it if needed). This is done because the same Terraform component vpc is used as the workspace prefix (in case of AWS S3 backend, folder in the S3 state bucket), and it's necessary to have different subfolders (ue2-dev-vpc-1 and ue2-dev-vpc-2 instead of just ue2-dev) to store the Terraform state files.
> I have two competing components overwriting the backend.json file please provide more details on that in general, the backend.json file is generated per Terraform component and it's the same for any number of instances of an Atmos component (for which Atmos generates different Terraform workspaces (which are sub-folders in the S3 bucket)