Hey I have a question about atmos and terraform wo...
# atmos
m
Hey I have a question about atmos and terraform workspaces, did the naming change on v1.206.2? It looks like now the terraform workspace by default is not including component name and namespace, Is this intentional or did I miss something?? So before the calculated tf workspace will be like this:
{tenant}-{environment}-{stage}-{component}-{namespace}
and now the calculated tf workspace is:
{tenant}-{environment}-{stage}
e
Can you see if using name template works?
(Would avoid using name pattern )
But no deliberate change was made to affect that
That also dropped namespace in your example.
Are you using locals?
m
Yeah namespace and component name where drop, I was about to test name template flag, is this what you mean?
this 1
I'm not using locals, I'm waiting for the fix for functions hehehe
👍 1
e
m
I had to run but I will test in a bit and let you know
I do have a stack name template in atmos.yaml but it's the default one:
Copy code
stacks:
  name_template: "{{ .vars.tenant }}-{{ .vars.environment }}-{{ .vars.stage }}"
But I don't think that is related since it work before
e
Maybe I am mixing things up.
@Andriy Knysh (Cloud Posse)
a
@Miguel Zablah by default, terraform workspaces were the stack names (defined as stack name template or ma,e pattern in
atmos.yaml
), so
{tenant}-{environment}-{stage}
would be correct if you have
Copy code
name_template: "{{ .vars.tenant }}-{{ .vars.environment }}-{{ .vars.stage }}"
the only time the namespace was different from this default was when we have multiple component instances using the same terraform component (https://atmos.tools/design-patterns/inheritance-patterns/multiple-component-instances)
i don't understand how this would be possible
Copy code
So before the calculated tf workspace will be like this:
{tenant}-{environment}-{stage}-{component}-{namespace}
if you provide some examples, we'll look at the issue
you can override TF workspaces for Atmos components https://atmos.tools/components/terraform/workspaces#terraform-workspace-override-in-atmos so maybe that's what you did before?
if you se issues or regression, please open a GH issue, and we'll fix it ASAP (and thanks for all the testing and improving Atmos)
m
Ah I see yeah the
namespace
part it was totally on me, my module name was
iam/namespace
that is why I though this bc your correct it's only:
Copy code
{tenant}-{environment}-{stage}-{component}
I will create an issue in a bit but let me just double check if this happens on older components bc maybe is something on my side
@Andriy Knysh (Cloud Posse) I found the issue. When I check older components they where okay so it was only the 3 new components this happened to use a different provider so I though maybe it was bc of this, it's not. The issue is that Atmos will not add the
{component}
suffix if the component name in catalog maches the
metadata.component
name/path. So since I name my component
ibm/vpc
and the tf code was on
ibm/vpc
they where the same and this happen on all 3 of my new components. this do not happened in older components bc I usually name them differently or don't add the prefix of the cloud. Ej
VPC
is my name and the component metadata is
aws/vpc
.
Now this can be fix by using the
terraform_workspace_template
or just naming differently but I believed it should always add the
component
as suffix
or at least we should update the docs to be more clear there is like a hint of it here: https://atmos.tools/components/terraform/workspaces
Copy code
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.
Bc of this I check my other components and try to dig dipper but it's not clear why is this.
This doesn't really affect state or anything else since this only for the terraform workspace itself but I though I should bring this up. The only issue is that if you use
terraform_workspace_pattern
after you apply without it, this will change the tf state So idk if this is consider and issue or not, what you guys think. PS: @Erik Osterman (Cloud Posse) Sorry if I did not explain myself enough I was talking about this workspaces
a
@Miguel Zablah thanks again. Yes, if the Atmos component name is the same as the terraform component name, the name is considered 'simple' (not derived) and Atmos does not append the component name to the TF namespace - this is correct behavior (similar to if you just used a simple component name like
vpc
). But you are 100% correct, we need to updte the docs to make it more clear, thanks.
@Gabriela Campana (Cloud Posse) please create a task to update the Atmos docs to clarify how Atmos calculates terraform workspaces for different configurations
✅ 1
m
Thanks to you!! Atmos is great!!