SAM Doctor

ERROR REFERENCE

Stack already exists during a CloudFormation create operation

A CloudFormation create operation targeted an existing stack name

A direct CreateStack call or a CREATE-type change set named a stack that already exists in the selected account and Region. The message is not proof that deletion is safe or that the current caller can even inspect the stack.

WHAT IT MEANS

What this error means

An error occurred (AlreadyExistsException) when calling the CreateStack operation:
Stack [my-app] already exists

An error occurred (ValidationError) when calling the CreateChangeSet operation:
Stack [my-app] already exists and cannot be created again with the changeSet [deploy].

CREATE is only for a stack that does not exist. The name may belong to the deployment you intended to update, a different profile or Region, another samconfig.toml environment, or a separate deployment entirely.

SAFE NEXT STEPS

Confirm the stack before changing anything

  1. Confirm the caller and Region, then inspect the exact stack read-only.
    aws sts get-caller-identity
    aws cloudformation describe-stacks --stack-name YOUR_STACK --region YOUR_REGION \
      --query "Stacks[0].[StackId,StackStatus,CreationTime]" --output table
  2. Handle a review stack carefully. If the status is REVIEW_IN_PROGRESS, list its change sets before making any decision:
    aws cloudformation list-change-sets --stack-name YOUR_STACK --region YOUR_REGION
  3. Choose the intended path. Use an update-capable path only for the stack you own and expect to update. Otherwise correct the stack name, profile, Region, SAM configuration environment, or change-set type; use another name when a different deployment owns this one.
  4. Do not turn every failed lookup into "absent". A denied describe-stacks request is a permissions problem, not evidence that no stack exists. Branch only on CloudFormation's explicit not-found response.
  5. Do not delete from this message alone. Review the stack identity, status, retained resources, and termination protection before selecting a cleanup path.

AUTOMATE THE TRIAGE

Diagnose this automatically

SAM Doctor recognizes the direct create and CREATE-type change-set forms, keeps S3 bucket conflicts and terminal-stack recovery separate, and runs locally without AWS credentials or log upload.

python -m pip install sam-doctor
sam-doctor diagnose deployment.log --format markdown

RELATED