pulumi: Add "how to fix" instructions for "already exists" errors
Hello!
- Vote on this issue by adding a 👍 reaction
- If you want to implement this feature, comment to let us know (we’ll work with you on design, scheduling, etc.)
Issue details
When running pulumi up and getting an “already exists” error. It would be useful to also provide additional helpful messages for how to resolve such error. An example message may be:
To resolve this error, you can:
1. Change the name of your locally declared resource.
2. Import the resource.
3. Manually delete the external resource from the provider and rerun.
To Import, run this (though the variables here should actually be filled out, as pulumi already knows exactly what values should exist):
pulumi import [type] [name] [id] --parent [parent] --provider [provider]
### Affected area/feature
CLI
About this issue
- Original URL
- State: open
- Created 4 years ago
- Reactions: 26
- Comments: 20 (6 by maintainers)
This is the worst thing about pulumi. When i am developing infra and something fails in a odd way (as often happens when developing) pulumi cannot recover automatically from the situation and the commands to fix things are baroque. Or maybe they are very easy but there is no documentation.
I am a long time user of terraform and in this regard pulumi is very much worse
Concrete example. We can work around this to a degree by doing the following:
But this requires telling pulumi when you are importing and is a one off. It would be nice to do something like:
Or even just be able to set that globally.
I have the same issue for some resource such as create
Cloudflare recordand createecr userresources.If two developers are working separately with
Pulumiin local mode, and one of them has already created a resource such as a Cloudflare record or an ECR user, the other developer may encounter this error when runningPulumi up. This error occurs because the resource already exists and cannot be created again.I think this error occurs because the second developer does not have that resource in their state.
I would like the
Pulumi refreshcommand to synchronize the stack and update the state in order to prevent this error from occurring.#3388
In cases where the development team is not using
Pulumi Cloudand each developer login in locally with the commandpulumi login --local, conflicts may arise when runningpulumi up -yafter making changes.To prevent such conflicts, developers should follow these steps to synchronize their stack states :
Export the stack after making changes with
pulumi up -y:Commit the changes and push them to the repository:
Retrieve the stack changes by importing the changes:
By following these steps, developers ensure that they have the latest stack state and can avoid errors related to resource already exist during local development.
this 409 issue is exactly why i’m switching back to terraform.
@nabby27 I have experienced this issue and I would love to have a go at it.
It would be useful to have a flag with pulumi up to say import the resource(s) if it exists. The situation for this is if the stack file is missing or corrupt and/or you want to start from clean stack. So you have the code and the resources exists but there is no stack. You shouldn’t have to specify the id, it should be able to find by name.
Again, I’m confused because as I understand it Terraform is exactly the same in this regard!?
Both systems will error if you try to create something that already exists, you can’t create a new S3 bucket called “foo”, if that bucket already exists. In fact if anything Pulumi should be better here because by default we suffix names with random characters to avoid name collisions.
So what is Terraform doing here that’s better than us? I don’t think it’s the idea in the first post on this issue, although I do think that’s a good idea.
I mean when running Pulumi up, specifying a resource, with a name, or ID, etc that already exists. Pulumi will fail to create the resource because of the conflict. Leading me to usually either import or change the name of the locally declared resource.