Pulumi "stack ... already has a resource" on import in CI
Pulumi found a resource with the same name or URN already recorded in the stack state, so it refuses to add a second. This usually comes from importing a resource the stack already manages, or from two program resources sharing a name.
What this error means
A pulumi import or pulumi up step fails with "error: stack 'X' already has a resource named 'Y'" or "duplicate resource URN".
error: stack 'dev' already has a resource named 'app-bucket'Common causes
Importing a resource the stack already manages
A pulumi import targets a resource whose name already exists in state, so Pulumi will not create a duplicate entry.
Two program resources share a name
The program declares two resources of the same type with the same logical name under the same parent, which is not allowed.
How to fix it
Use a unique name or skip the import
- Check
pulumi stack --show-urnsto see what is already in state. - If the resource is already managed, remove the redundant import.
- If it is genuinely new, give it a distinct logical name.
pulumi stack --show-urnsImport under a different name when both must exist
Pass a distinct name to the import so it does not collide with the existing resource.
pulumi import aws:s3/bucket:Bucket app-bucket-imported my-existing-bucketHow to prevent it
- Inspect existing URNs before importing into a live stack.
- Keep logical resource names unique within a parent.
- Make import steps idempotent so replays do not duplicate resources.