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

limited-rain-96205

11/20/2019, 1:06 AM
Hi all, what is the correct way to create a new Pulumi project using an existing stack? According to the output of
pulumi new --help
, we should use `--stack`:
Copy code
-s, --stack string              The stack name; either an existing stack or stack to create; if not specified, a prompt will request it
However, if I do that with an existing stack, it gives an error:
Copy code
$ pulumi new -n p3 --stack dev
Please choose a template: gcp-typescript             A minimal Google Cloud TypeScript Pulumi program
This command will walk you through creating a new Pulumi project.
Enter a value or leave blank to accept the (default), and press <ENTER>.
Press ^C at any time to quit.
project description: (A minimal Google Cloud TypeScript Pulumi program) 
Created project 'p3'
Enter your passphrase to protect config/secrets: 
Re-enter your passphrase to confirm: 
error: stack 'dev' already exists
w

white-balloon-205

11/20/2019, 1:15 AM
What exactly are you looking for when you say “new project with an existing stack”? In general that isn’t really possible - the stack is an instance of some existing project. But there is likely a way to accomplish what you are looking for if you can share more details.
l

limited-rain-96205

11/20/2019, 3:10 AM
I just want to have multiple projects each with their own 'dev', 'prod', etc stacks
In other words, it doesn't necessarily need to be the same stack, I just want to have the same name
w

white-balloon-205

11/20/2019, 3:26 AM
Are you using the local backend? I believe you are hitting https://github.com/pulumi/pulumi/issues/2522 which causes stack names to be a shared namespace across different projects when using the local backend whereas stack names are project-scoped in the Pulumi service backend. This is definitively something we want to fix as it leads to problems like you are seeing here. Mind upvoting that issue and/or adding details of your use case? FWIW - a workaround many folks use in practice is to use
<project>-<stack>
as the stack name.
l

limited-rain-96205

11/20/2019, 3:44 AM
Ahh okay, that makes sense. Yes, I've been using the local backend, as well as a GCS bucket.