SKILL.md
$27
Validate a template before deployment
Run three validation layers in order — each catches different classes of errors:
- Syntax and schema — validate-cloudformation-template SOP (cfn-lint)
- Security and compliance — check-cloudformation-template-compliance SOP (cfn-guard)
- Pre-deployment — cloudformation-pre-deploy-validation SOP (change set +
describe-eventsAPI)
Critical: Pre-deployment validation errors are retrieved via aws cloudformation describe-events --change-set-id <arn> --region <region>. Do NOT use describe-stack-events — that API does not return validation errors. Note: describe-events is a newer API — if the command is not recognized, upgrade the AWS CLI to the latest version.
Troubleshoot a failed deployment
When a stack is in a failed state (CREATE_FAILED, ROLLBACK_COMPLETE, UPDATE_ROLLBACK_FAILED, etc.), follow the troubleshoot-deployment SOP.
Key points:
- Use
aws cloudformation describe-events --stack-name <name> --filters FailedEvents=true --region <region>to get only failure events. Do NOT usedescribe-stack-events— that API does not support the--filtersparameter. Do NOT use--queryJMESPath filters as a substitute — use the--filtersparameter directly.
- Examine EVERY failed event's
ResourceStatusReason. If a failure has a specific error message (e.g., "not authorized to perform", "already exists"), it is a real failure. If a failure says "Resource creation cancelled" with no specific error, it is a cascade caused by rollback — it does not tell you what would have gone wrong.
- When multiple resources have their own specific errors, they are parallel failures from a shared root cause (e.g., an IAM role missing permissions for multiple services). Enumerate ALL the specific permission gaps, not just the first one, so the developer can fix everything in one pass.
- Cancelled resources may have their own issues that only surface on the next deployment attempt. Warn the developer that additional failures may appear after fixing the visible ones.
- Classify the fix as template-level (change the template) or environment-level (fix IAM, quotas, resource state) — do not propose template changes for environment issues
Decision Guide
User intent
Action
Write or modify a template
Author task + best-practices checklist
Check a template before deploying
Validation pipeline (3 layers)
Stack failed or is stuck
Troubleshoot-deployment SOP
Unsure about a resource property
Resource property lookup SOP
CloudFormation vs CDK
Recommend CloudFormation when: existing templates are YAML/JSON, workload is simple (< 50 resources), team has no CDK experience. Recommend CDK when: workload benefits from reusable abstractions, team already uses CDK.
Troubleshooting
Symptom
Likely cause
Action
Template validates but deployment fails
Runtime issue (IAM, quotas, AMI availability)
Use troubleshoot-deployment SOP
describe-events returns empty
CLI may be outdated, or change set still creating
Upgrade CLI; wait for terminal status
Agent uses describe-stack-events
Legacy API — does not support filters or return validation errors
Switch to describe-events (see validation and troubleshooting SOPs for correct parameters)
Stack stuck in UPDATE_ROLLBACK_FAILED
Resource in inconsistent state
Use troubleshoot-deployment SOP to identify stuck resource(s) before continue-update-rollback