Skip to content
Latchkey

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".

pulumi
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

  1. Check pulumi stack --show-urns to see what is already in state.
  2. If the resource is already managed, remove the redundant import.
  3. If it is genuinely new, give it a distinct logical name.
Terminal
pulumi stack --show-urns

Import under a different name when both must exist

Pass a distinct name to the import so it does not collide with the existing resource.

Terminal
pulumi import aws:s3/bucket:Bucket app-bucket-imported my-existing-bucket

How 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.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →