already exists in stack ☁️ AWS

CloudFormation: Resource ... already exists (AlreadyExists / already exists in stack)

The template tries to create a resource with a fixed name that already exists — created manually, by another stack, or left over after deletion (retained resource).

Seen on: AWS

Meaning

Explicit names (BucketName, TableName, RoleName, log group names) must be unique. Retained resources from deleted stacks and log groups auto-created by Lambda are common culprits.

Common causes

  • Resource with the same name created outside CloudFormation
  • Another stack owns a resource with that name
  • DeletionPolicy: Retain left it behind
  • Lambda auto-created its log group before the stack did

⚡ Quick fix

  1. Let CloudFormation generate names (remove the explicit name)
  2. Import the existing resource into the stack
  3. Delete the leftover resource if safe

Detailed fix by platform

AWS CLI

  1. aws cloudformation describe-stack-events --stack-name app --query "StackEvents[?contains(ResourceStatusReason, 'already exists')].[LogicalResourceId,ResourceStatusReason]"

How to diagnose

  1. Owner — Which stack/tool created it?
  2. Name — Explicit name in the template?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.