Launch, configure, and manage EC2 instances with best practices
Launch production-ready EC2 instances with best practices including EBS optimization, detailed monitoring, and IMDSv2 when you need to deploy servers on AWS. Automatically retries with subnet failover on capacity errors.
/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/ec2-userdata.shassets/schema.jsonreferences/GUIDE.mdreferences/PATTERNS.mdscripts/validate.pyDeploy and manage EC2 instances with production-ready configurations.
| Attribute | Value |
|---|---|
| AWS Service | EC2 |
| Complexity | Medium |
| Est. Time | 5-15 min |
| Prerequisites | VPC, Security Group, Key Pair |
| Parameter | Type | Description | Validation |
|---|---|---|---|
| instance_type | string | EC2 instance type | Valid type (m6i.large) |
| ami_id | string | AMI ID | ami-[a-z0-9]{17} |
| subnet_id | string | Target subnet | subnet-[a-z0-9]{17} |
| security_group_ids | array | Security groups | Non-empty array |
| Parameter | Type | Default | Description |
|---|---|---|---|
| key_name | string | null | SSH key pair name |
| iam_instance_profile | string | null | IAM role ARN |
| user_data | string | null | Base64 startup script |
| ebs_optimized | bool | true | EBS optimization |
| monitoring | bool | true | Detailed monitoring |
aws ec2 run-instances \
--image-id ami-0abcdef1234567890 \
--instance-type m6i.large \
--subnet-id subnet-12345678 \
--security-group-ids sg-12345678 \
--key-name my-key \
--iam-instance-profile Name=MyRole \
--ebs-optimized \
--monitoring Enabled=true \
--metadata-options HttpTokens=required \
--tag-specifications 'ResourceType=instance,Tags=[{Key=Name,Value=MyServer}]'
#!/bin/bash
set -e
yum update -y
yum install -y docker
systemctl enable docker
systemctl start docker
def launch_with_retry(params, max_retries=3):
for attempt in range(max_retries):
try:
return ec2.run_instances(**params)
except ec2.exceptions.InsufficientInstanceCapacity:
params['SubnetId'] = get_alternate_subnet()
time.sleep(2 ** attempt)
raise Exception("Failed to launch instance")
| Symptom | Cause | Solution |
|---|---|---|
| InsufficientInstanceCapacity | AZ full | Try different AZ |
| InvalidAMIID | AMI not in region | Copy AMI |
| Unauthorized | IAM missing | Check permissions |
| Pending forever | ENI issue | Check subnet IPs |
| Workload | Family | Key Feature |
|---|---|---|
| Web/API | M6i, M7g | Balanced |
| Compute | C6i, C7g | High CPU |
| Memory | R6i, X2idn | High memory |
| GPU/ML | P4d, G5 | NVIDIA GPU |
| Strategy | Savings |
|---|---|
| Reserved Instances | 30-60% |
| Savings Plans | 30-72% |
| Spot Instances | Up to 90% |
| Right-sizing | 10-50% |
def test_ec2_launch():
# Arrange
params = {
"ImageId": get_latest_amazon_linux_ami(),
"InstanceType": "t3.micro",
"MaxCount": 1, "MinCount": 1
}
# Act
response = ec2.run_instances(**params)
instance_id = response['Instances'][0]['InstanceId']
# Assert
waiter = ec2.get_waiter('instance_running')
waiter.wait(InstanceIds=[instance_id])
# Cleanup
ec2.terminate_instances(InstanceIds=[instance_id])
assets/ec2-userdata.sh - Sample user data scriptThis 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 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 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.