https://pulumi.com logo
#general
Title
# general
b

busy-pizza-73563

03/28/2019, 10:20 PM
I'm a bit confused about how [organizations, ]stacks and projects are namespaced. My expectation was that stacks are namespaced by project, but in reality they appear to be global. Reading https://pulumi.io/reference/organizing-stacks-projects.html , is it best practice to name your stacks like
project-name/environment-name
? I'm using the filesystem backend, it that's in any way relevant.
My confusion also comes from the fact that if I name my stack
environment-name
only, in
pulumi
output I can see
Copy code
Type                 Name
pulumi:pulumi:Stack  project-name-environment-name
c

colossal-beach-47527

03/28/2019, 10:32 PM
We’ve actually gone back and forth over stack namespaces and things. So it is possible some of our documentation is out of date. Today a stack’s identity is its organization, project name, and stack name. So you can have multiple stacks with the same name, e.g.
production
. You can also have multiple stacks within the same project, e.g.
payment-system
. As far as best practices, yes, we would encourage you to name your stacks something related to the environment. So your production stack would be named
production
, and so on. Before we changed the stack identity model (which was a month or so ago IIRC), that meant you needed to name things
project-name/env-name
. But now you should be able to just name your stacks
env-name
. (And it will be OK, since we use the project name as part of its identity.) /cc @bitter-oil-46081 who can cover this in better detail.
b

bitter-oil-46081

03/28/2019, 10:33 PM
Right now due to a bug there are not namespace by project when using the filesystem backend. It is something we are going to fix.
b

busy-pizza-73563

03/28/2019, 10:33 PM
Hm, I'm pretty sure that I couldn't create a stack with the same name as one in a different project.
b

bitter-oil-46081

03/28/2019, 10:34 PM
What Chris said above applied when using pulumi.com to store state. For now, I would recommend that you just name them <project-name>-<stack-name> when using the filesytem backend and then you can rename them when the issue is fixed.
b

busy-pizza-73563

03/28/2019, 10:35 PM
Right now due to a bug there are not namespace by project when using the filesystem backend.
Oh, ok, that was my best guess, too.
b

bitter-oil-46081

03/28/2019, 10:35 PM
Sorry!
b

busy-pizza-73563

03/28/2019, 10:36 PM
Would that only rename the stacks and leave all other resources untouched?
That's not really a big deal, only that I need additional logic to extract the actual environment name out of the stack name.
(e.g.
dev
out of
aws-infra-dev
)
Last question, does
pulumi.StackReference()
expect only that
<project-name>-<stack-name>
name? Or should it be
<project-name>/<project-name>-<stack-name>
?
I guess I'll figure it out for myself, but was just curious, and not at my working machine ATM.
c

colossal-beach-47527

03/28/2019, 10:49 PM
Re:
pulumi.StackReference()
, both would probably work. If I recall correctly, the API was written in such a way that we would automatically support newer and older stack identities seamlessly. But we will report an error if it is ambiguous. (e.g. if two stacks have the same name, and only differ via project name.) But when using the local backend, I cannot say for sure.
b

busy-pizza-73563

03/28/2019, 10:56 PM
Thanks all, I'll get back to you if I have further issues!
Right now due to a bug there are not namespace by project when using the filesystem backend.
@bitter-oil-46081 Do you know if there's an issue I can follow?