Infrastructure as Code with CloudFormation templates and stacks
Deploys and manages AWS infrastructure using CloudFormation templates. Triggers when you request to create, update, or validate CloudFormation stacks from YAML/JSON template files.
/plugin marketplace add pluginagentmarketplace/custom-plugin-aws/plugin install pluginagentmarketplace-aws-cloud-assistant@pluginagentmarketplace/custom-plugin-awsThis skill inherits all available tools. When active, it can use any tool Claude has access to.
assets/config.yamlassets/schema.jsonassets/vpc-template.yamlreferences/GUIDE.mdreferences/PATTERNS.mdscripts/validate.pyCreate and manage infrastructure as code with CloudFormation.
| Attribute | Value |
|---|---|
| AWS Service | CloudFormation |
| Complexity | Medium-High |
| Est. Time | 10-60 min |
| Prerequisites | IAM permissions |
| Parameter | Type | Description | Validation |
|---|---|---|---|
| stack_name | string | Stack name | ^[a-zA-Z][-a-zA-Z0-9]{0,127}$ |
| template_path | string | Template file path | Valid YAML/JSON |
| Parameter | Type | Default | Description |
|---|---|---|---|
| parameters | object | {} | Stack parameters |
| capabilities | array | [] | CAPABILITY_IAM, etc. |
| tags | object | {} | Resource tags |
| termination_protection | bool | false | Prevent deletion |
| rollback_on_failure | bool | true | Rollback on error |
AWSTemplateFormatVersion: '2010-09-09'
Description: 'Production VPC with 3-tier architecture'
Parameters:
Environment:
Type: String
AllowedValues: [dev, staging, prod]
Mappings:
RegionMap:
us-east-1:
AMI: ami-12345678
Conditions:
IsProd: !Equals [!Ref Environment, prod]
Resources:
VPC:
Type: AWS::EC2::VPC
Properties:
CidrBlock: 10.0.0.0/16
Tags:
- Key: Name
Value: !Sub ${Environment}-vpc
Outputs:
VPCId:
Value: !Ref VPC
Export:
Name: !Sub ${Environment}-VPCId
# Validate template
aws cloudformation validate-template \
--template-body file://template.yaml
# Create stack
aws cloudformation create-stack \
--stack-name my-stack \
--template-body file://template.yaml \
--parameters ParameterKey=Environment,ParameterValue=prod \
--capabilities CAPABILITY_IAM CAPABILITY_NAMED_IAM \
--tags Key=Environment,Value=Production \
--enable-termination-protection
# Wait for completion
aws cloudformation wait stack-create-complete --stack-name my-stack
# Create change set (preview changes)
aws cloudformation create-change-set \
--stack-name my-stack \
--change-set-name my-changes \
--template-body file://template.yaml \
--parameters ParameterKey=Environment,ParameterValue=prod
# Review changes
aws cloudformation describe-change-set \
--stack-name my-stack \
--change-set-name my-changes
# Execute change set
aws cloudformation execute-change-set \
--stack-name my-stack \
--change-set-name my-changes
Resources:
VPCStack:
Type: AWS::CloudFormation::Stack
Properties:
TemplateURL: https://s3.amazonaws.com/bucket/vpc.yaml
Parameters:
Environment: !Ref Environment
DatabaseStack:
Type: AWS::CloudFormation::Stack
DependsOn: VPCStack
Properties:
TemplateURL: https://s3.amazonaws.com/bucket/rds.yaml
Parameters:
VPCId: !GetAtt VPCStack.Outputs.VPCId
| Symptom | Cause | Solution |
|---|---|---|
| CREATE_FAILED | Resource error | Check events for details |
| UPDATE_ROLLBACK | Update failed | Review change set |
| DELETE_FAILED | Resource in use | Remove dependencies |
| ROLLBACK_COMPLETE | Creation failed | Delete and fix |
validate-template)?# Get stack events
aws cloudformation describe-stack-events \
--stack-name my-stack \
--query 'StackEvents[?ResourceStatus==`CREATE_FAILED`]'
Resource handler returned message: ... → Provider-specific error
Circular dependency between resources → Use DependsOn carefully
Export ... cannot be updated → Update dependent stacks first
Template format error → Check YAML syntax
def test_cloudformation_template():
# Arrange
template_body = open('template.yaml').read()
# Act - Validate
response = cfn.validate_template(TemplateBody=template_body)
# Assert
assert 'Parameters' in response
assert response['Capabilities'] == ['CAPABILITY_IAM']
# Act - Create stack (dry run)
# Use change set with no execute for testing
assets/vpc-template.yaml - Production VPC templateThis skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.