cajias/claude-skills/cloudformation-kms-alias-collision
Claude Code and agent skill by cajias/claude-skills
- community
Checking that the SKILL.md file is still in the repository.
Fix CloudFormation deployment failures caused by KMS alias collisions. Use when: (1) CDK deploy fails with "AWS::EarlyValidation::ResourceExistenceCheck" error, (2) Multiple CDK stacks create KMS keys with similar aliases, (3) Deployment fails before changeset execution due to resource existence check. Covers diagnosing KMS alias conflicts and resolving them in CDK stacks.
Install
npx vskill@latest install cajias/claude-skills/cloudformation-kms-alias-collisionSKILL.md
The same SKILL.md was published earlier as cajias/claude-skills/cloudformation-kms-alias-collision.
CloudFormation KMS Alias Collision Resolution
Problem
CloudFormation deployment fails during the Early Validation phase with AWS::EarlyValidation::ResourceExistenceCheck error when a KMS alias already exists in the account from another stack or previous deployment.
Context / Trigger Conditions
- CDK deploy fails before changeset execution
- Error message contains
AWS::EarlyValidation::ResourceExistenceCheck - Error references a KMS Key or Alias resource
- Multiple stacks define similar KMS keys (e.g., for shared encryption purposes)
- Stack was working but fails after another stack with similar resources was deployed
Example error:
Solution
Step 1: Identify the Conflicting Alias
List existing KMS aliases to find the conflict:
Example:
Step 2: Determine the Source
Check which stack created the existing alias:
- Look at the
TargetKeyIdfrom the alias listing - Find the key in CloudFormation stacks using:
Step 3: Resolve the Conflict
Option A: Use a Unique Alias Name (Recommended for new resources)
Change the alias name to be unique per stack:
Option B: Share the Existing Key (For truly shared resources)
If the key should be shared, import it instead of creating:
Option C: Remove Alias from Conflicting Stack
If the original stack shouldn't have the alias, remove it there first.
Step 4: Deploy
After making changes, deploy again:
Verification
- Deployment completes without Early Validation errors
- Both stacks deploy successfully with their respective KMS keys
- List aliases to confirm both exist:
Example
In this real case, two CDK stacks were creating KMS keys:
- MCPGatewayStack (auth-service-construct): Created
alias/mat-correlation-token - DataStack: Tried to create the same alias for a shared correlation token key
Resolution was to rename DataStack's alias:
Notes
- Early Validation: CloudFormation's Early Validation phase checks for resource
existence before creating changesets, catching conflicts early
- Alias Uniqueness: KMS aliases must be unique within an account (not just a stack)
- Alias Names: Aliases are automatically prefixed with
alias/by AWS - Migration Path: If resources should be shared, plan a migration to consolidate
onto a single key, then remove the duplicate
- RemovalPolicy.RETAIN: Keys with RETAIN policy stay after stack deletion,
potentially causing future conflicts
Related Issues
- IAM role/policy name conflicts (similar pattern)
- S3 bucket name conflicts (must be globally unique)
- SSM parameter name conflicts (namespace-based)
References
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/cloudformation-kms-alias-collision/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/cajias/claude-skills/cloudformation-kms-alias-collision)