Hi, how do I create a new stack for an existing pr...
# general
g
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
Pass --stack argument. Eg:
pulumi preview --stack qa
g
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
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
so I should have the project yaml at the root, and a stack per subfolder? 🙂
f
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
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
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
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
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
So you are running pulumi stack init in the root of the project which holds the Pulumi.yaml file?
g
not at the moment - right now I have a pulumi.yaml in each stack folder. Open to the idea I shouldn't though
f
Yea a Pulumi.yaml file is created once per project.
g
perhaps a previous version of the CLI allowed me to do this when it shouldn't have
f
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
I want to create a different node project for each stack, with different everything etc
f
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
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
Ah yea that might be the case. I haven't actually tried to create a project with the same name.
g
think this might make sense, thanks for talking it through 🙂
f
Oh yea anytime! 😄