https://pulumi.com logo
g

gorgeous-elephant-23271

04/11/2020, 8:38 PM
Hi, how do I create a new stack for an existing project? When I do
pulumi new
I get
Sorry, 'projectname' is not a valid project name. A project with this name already exists.
, and when I do
pulumi stack init
I get
error: no Pulumi project found in the current working directory
s

swift-oxygen-28374

04/11/2020, 8:41 PM
Pass --stack argument. Eg:
pulumi preview --stack qa
g

gorgeous-elephant-23271

04/11/2020, 8:43 PM
sorry that doesn't quite make sense - I'm not trying to
up
or
destroy
a stack, I'm trying to create a new stack in a new folder
my structure is
project/stacka
project/stackb
project/stackc
unless I misunderstand 🙂
like, I want to run
pulumi new --project project
f

fast-dinner-32080

04/11/2020, 8:46 PM
a project has multiple stacks you create a new project with a single pulumi.yaml which then you can create different stacks in it by running 'pulumi stack init stackName' which will create different stack config files for that single project. If you want multiple projects with a single stack then you run pulumi new and must give it a unique name vs other projects you already have.
g

gorgeous-elephant-23271

04/11/2020, 8:47 PM
so I should have the project yaml at the root, and a stack per subfolder? 🙂
f

fast-dinner-32080

04/11/2020, 8:49 PM
You don't need to create new files for a stack. You have a single project with a single code base that runs for each stack. If you want different resources for each stack then you will need to create logic to load the files that have the desired resources or build in conditions.
so like this project/Pulumi.yaml project/myCodeFiles
then you can create different stacks for that single project by running pulumi stack init stackName
s

swift-oxygen-28374

04/11/2020, 8:50 PM
so I should have the project yaml at the root, and a stack per subfolder?
ah, ok. I misunderstood your question. I'm brand new to Pulumi!
g

gorgeous-elephant-23271

04/11/2020, 8:50 PM
yeah - something about my folder structure is throwing off the tooling
I'm using micro stacks and for some reason I can no longer create new micro stacks
f

fast-dinner-32080

04/11/2020, 8:51 PM
yea stacks are like workspaces/environments
it has different configuration from another stack
but runs in the same project
so one code base with multiple stacks
which you can add logic to load in different code files or have conditions per stack
The programming model document might go over it better than I did 😄 https://www.pulumi.com/docs/intro/concepts/programming-model/
g

gorgeous-elephant-23271

04/11/2020, 9:04 PM
sorry I'm just not sure you're understanding my problem, I understand the abstractions. I'm trying to use a monolithic model where I have a single project and multiple stacks (one per concern), and for some reason I'm no longer able to create new stacks in my project
I appreciate you trying to help, it can get a bit confusing when we're all new though 🙂
f

fast-dinner-32080

04/11/2020, 9:06 PM
So you are running pulumi stack init in the root of the project which holds the Pulumi.yaml file?
g

gorgeous-elephant-23271

04/11/2020, 9:06 PM
not at the moment - right now I have a pulumi.yaml in each stack folder. Open to the idea I shouldn't though
f

fast-dinner-32080

04/11/2020, 9:07 PM
Yea a Pulumi.yaml file is created once per project.
g

gorgeous-elephant-23271

04/11/2020, 9:07 PM
perhaps a previous version of the CLI allowed me to do this when it shouldn't have
f

fast-dinner-32080

04/11/2020, 9:07 PM
so you would only want one of those.
for the whole project
Then when you create a stack and add configuration to it, it will create configuration files like "Pulumi.StackName.yaml" at the root next to the pulumi.yaml file. which maybe what you are thinking of
g

gorgeous-elephant-23271

04/11/2020, 9:09 PM
I want to create a different node project for each stack, with different everything etc
f

fast-dinner-32080

04/11/2020, 9:10 PM
Ah so in that case you just need multiple projects. So running a pulumi new in each of the project directories you want and giving it a unique project name.
so you want a 1 to 1 project and stack
and not using multiple stack per project
g

gorgeous-elephant-23271

04/11/2020, 9:11 PM
righto, so when I ran
pulumi new
previously, it looks like the tooling incorrectly allowed me to create new projects with the same name
it all still worked, and grouped them correctly on the website, but appears to be logically incorrect
f

fast-dinner-32080

04/11/2020, 9:12 PM
Ah yea that might be the case. I haven't actually tried to create a project with the same name.
g

gorgeous-elephant-23271

04/11/2020, 9:12 PM
think this might make sense, thanks for talking it through 🙂
f

fast-dinner-32080

04/11/2020, 9:13 PM
Oh yea anytime! 😄
8 Views