https://pulumi.com logo
Title
b

bumpy-summer-9075

05/05/2021, 5:34 PM
Where is the "current stack" saved (for instance when running
pulumi stack select foo
)? How can I see which stack is currently selected?
r

red-match-15116

05/05/2021, 5:35 PM
pulumi stack ls
should show a
*
next to the current stack
πŸ‘ 1
b

bumpy-summer-9075

05/05/2021, 5:37 PM
That works. Where is that saved? Seems to be
~/.pulumi/workspaces
, not entirely sure I understand how workspaces work tho. Thanks πŸ™‚
πŸ‘πŸ½ 1
r

red-match-15116

05/05/2021, 5:41 PM
now you’re asking the hard questions πŸ˜† I imagine somewhere in
~/.pulumi
πŸ˜„ 1
Aha looks like you got it. I think of workspaces as the representation of the pulumi project on your machine
b

bored-oyster-3147

05/05/2021, 5:43 PM
FYI most (if not all) stack related commands in the CLI accept a
--stack
or
-s
argument to specify the stack you want to operate on, if you want to forgo messing with what stack is currently selected
b

bumpy-summer-9075

05/05/2021, 5:46 PM
I would have liked to have the equivalent of
terraform workspace show
but
pulumi stack ls
will work for now (albeit a bit slow). I do use the
--stack
command sometimes, especially since all my stacks are in the same project (because of https://github.com/pulumi/pulumi/issues/2814)
b

bored-oyster-3147

05/05/2021, 5:47 PM
That issue doesn't force all your stacks to be in the same project, it just means that project name is not part of stack identity with S3 backend. You could have separate projects if you wanted, you would currently just need to namespace your stack names by project name
b

bumpy-summer-9075

05/05/2021, 5:55 PM
I guess I confused the word project, they are in different projects (i.e. different folders with a Pulumi.yaml each), but
pulumi stack ls
still returns all the stacks of all the projects that share the backend. So I could technically have
.
β”œβ”€β”€ a
β”‚Β Β  └── Pulumi.yaml
└── b
    └── Pulumi.yaml
and go into
b
and do
pulumi stack select a.dev
b

bored-oyster-3147

05/05/2021, 5:58 PM
ah yea, I guess in that sense they are all in the same project in that all stacks are always accessible. my bad
b

bumpy-summer-9075

05/05/2021, 6:00 PM
No worries! I was kinda hoping the current selected stack was easily accessible (say an environment variable) so that way I could at least have a different TTY in each folder, each with a different stack selected. Right now I either have to use
-s
on every command, or change selected stack in each folder (but that's very error prone)
b

bored-oyster-3147

05/05/2021, 6:08 PM
when you're developing locally it's definitely a pain. But I think when you're setting up your pipelines and automation just specifying
-s
on everything is a good solution