Pulumi: `pulumi new`: Require a unique project instead of unique stack

Created on 25 Feb 2019  路  4Comments  路  Source: pulumi/pulumi

Today, when creating a new project with pulumi new, we check to ensure the stack doesn't already exist. If it does exist, we show an error, and ask the user to choose another stack name:

$ pulumi new typescript
This command will walk you through creating and deploying 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 name: (tags2)      
project description: (A minimal TypeScript Pulumi program) 
Created project 'tags2'

stack name: (dev) 
Sorry, could not create stack 'dev': stack 'dev' already exists
stack name: (dev) 

This made sense when stack names had to be unique within an organization, but now that the project is part of the stack's identity, warning that the stack already exists is _strange_, as it will only happen if you choose a project name that already exists.

Instead, we really should be presenting an error if the _project_ already exists. That way, users will actually be creating a new project and not unknowingly creating a new stack in an existing project (we don't want this flow to be a way to add a new stack to an existing project).

arecli kinbug

All 4 comments

This has been causing us a lot of grief as we've just started trying out pulumi. Glad to see it's been recognized as a bug already.

The fix involves making a HEAD request to api/stacks/<organization>/<project>. The API will return 200 if the project exists and 404 if it doesn't.

Hi, I'm still getting this problem with the latest version of Pulumi (1.5.2).

Steps to recreate:

  1. Create a Pulumi project by doing pulumi new in an empty directory, selecting any template, and using the default values.
  2. Create another Pulumi project by doing pulumi new in a different empty directory, selecting any template, and ensuring the project name is different, but otherwise keeping the default values.
  3. Observe that it will fail on creating the stack name dev with the following error message:
    Sorry, could not create stack 'dev': stack 'dev' already exists

Also, if you try to get around this by passing in --stack dev, it gives the same error message. The docs are really not clear on this, and this ticket indicates that Stacks are unique within a Project, not globally unique. How is it supposed to behave?

@jsmichaels, I'm guessing you're logged-in locally rather than the Pulumi service? There's a known discrepancy between the local vs. service backends that we plan to address, tracked at #2522.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lindydonna picture lindydonna  路  5Comments

lukehoban picture lukehoban  路  3Comments

nesl247 picture nesl247  路  3Comments

joeduffy picture joeduffy  路  5Comments

joeduffy picture joeduffy  路  5Comments