itsmostafa/aws-agent-skills/ec2
- community
Checking that the SKILL.md file is still in the repository.
AWS EC2 virtual machine management — instances, security groups, key pairs, AMIs, EBS volumes, Auto Scaling Groups, Spot Instances, Session Manager, placement groups, and instance lifecycle automation. Trigger on ANY of these, even when EC2 isn't named explicitly: - Launching or provisioning: "spin up a server", "create a VM", "new instance", "run-instances", mention of instance types (t3, m5, c5, r6, g5, p4d, t4g, c7g, etc.) - SSH / connectivity problems: "connection refused", "connection timed out", "permission denied publickey", "can't connect to my instance", "SSH not working" - Instance management: resize, stop, start, terminate, reboot, change instance type - Cost optimization: stop dev instances overnight, save money on EC2, spot vs on-demand, reserved instances - Auto Scaling: ASG, launch template, mixed instances policy, scale to zero, scheduled scaling - Spot Instances: spot fleet, spot interruption, capacity-optimized, price-capacity-optimized - AMIs and backups: create image, custom AMI, EBS snapshot, DLM lifecycle policy, copy AMI - Monitoring: EC2 CPU utilization, CloudWatch metrics for instance, instance status checks, console output - Access methods: Session Manager, EC2 Instance Connect, bastion host, port forwarding - Security: IMDSv2, instance metadata, IAM role on instance, security group rules - User data and bootstrap scripts, cloud-init
Install
npx vskill@latest install itsmostafa/aws-agent-skills/ec2SKILL.md
AWS EC2
Amazon Elastic Compute Cloud (EC2) provides resizable compute capacity in the cloud.
Advanced patterns (Auto Scaling, Spot Fleets, Session Manager, Instance Connect, IMDS, Placement Groups, scheduled scaling): see instance-management.md.
Table of Contents
Core Concepts
Instance Types
| Category | Example | Use Case | |
|---|---|---|---|
| General Purpose | t3, m6i, t4g (Graviton) | Web servers, dev environments | |
| Compute Optimized | c6i, c7g (Graviton) | Batch processing, gaming | |
| Memory Optimized | r6i, r7g (Graviton) | Databases, caching | |
| Storage Optimized | i3, d3 | Data warehousing | |
| Accelerated | p4d, g5 | ML, graphics |
Graviton (ARM) instances (t4g, m7g, c7g, r7g) are ~20% cheaper than x86 equivalents for the same performance — worth considering for new workloads.
Purchasing Options
| Option | Description | |
|---|---|---|
| On-Demand | Pay by the hour/second | |
| Reserved | 1-3 year commitment, up to 72% discount | |
| Spot | Unused capacity, up to 90% discount — can be interrupted with 2-minute notice | |
| Savings Plans | Flexible commitment-based discount |
AMI (Amazon Machine Image)
Template containing OS, software, and configuration for launching instances. Use SSM Parameter Store to look up the latest official AMIs rather than hardcoding IDs:
Security Groups
Virtual firewalls controlling inbound and outbound traffic. Changes take effect immediately — no restart required.
Common Patterns
Launch an Instance
boto3:
User Data Script
OS package manager note:- Amazon Linux 2: useamazon-linux-extras install nginx1 -y—yum install nginxfails because nginx is not in the default AL2 repos- Amazon Linux 2023: usednf install -y nginx- Ubuntu: useapt-get install -y nginx- Amazon Linux 2 / RHEL:httpd(Apache) is always available viayum install -y httpd
Attach IAM Role
Create AMI from Instance
Auto Scaling Group with Spot (Modern Approach)
The recommended way to use Spot Instances at scale is via Auto Scaling Groups with a mixed-instances policy — not the legacy request-spot-instances API. This supports instance diversification to minimize interruptions.
See instance-management.md for the full setup. Quick example:
EBS Volume Management
CLI Reference
Instance Management
| Command | Description | |
|---|---|---|
aws ec2 run-instances | Launch instances | |
aws ec2 describe-instances | List instances | |
aws ec2 start-instances | Start stopped instances | |
aws ec2 stop-instances | Stop running instances | |
aws ec2 reboot-instances | Reboot instances | |
aws ec2 terminate-instances | Terminate instances | |
aws ec2 modify-instance-attribute | Modify instance settings |
Security Groups
| Command | Description | |
|---|---|---|
aws ec2 create-security-group | Create security group | |
aws ec2 describe-security-groups | List security groups | |
aws ec2 authorize-security-group-ingress | Add inbound rule | |
aws ec2 revoke-security-group-ingress | Remove inbound rule | |
aws ec2 authorize-security-group-egress | Add outbound rule |
AMIs
| Command | Description | |
|---|---|---|
aws ec2 describe-images | List AMIs | |
aws ec2 create-image | Create AMI from instance | |
aws ec2 copy-image | Copy AMI to another region | |
aws ec2 deregister-image | Delete AMI |
EBS Volumes
| Command | Description | |
|---|---|---|
aws ec2 create-volume | Create EBS volume | |
aws ec2 attach-volume | Attach to instance | |
aws ec2 detach-volume | Detach from instance | |
aws ec2 create-snapshot | Create snapshot | |
aws ec2 modify-volume | Resize/modify volume |
Best Practices
Security
- Use IAM roles instead of access keys on instances
- Restrict security groups — principle of least privilege
- Use private subnets for backend instances
- Enable IMDSv2 to prevent SSRF attacks
- Encrypt EBS volumes at rest
Performance
- Right-size instances — monitor and adjust
- Use EBS-optimized instances
- Choose appropriate EBS volume type (gp3 is the default good choice; io2 for high IOPS)
- Use placement groups for low-latency networking (see instance-management.md)
Cost Optimization
- Use Spot Instances for fault-tolerant workloads (batch, ML training, CI)
- Stop/terminate unused instances
- Use Reserved Instances or Savings Plans for steady-state workloads
- Delete unused EBS volumes and snapshots
- Consider Graviton (t4g, m7g, c7g) — ~20% cheaper for same performance
Reliability
- Use Auto Scaling Groups for high availability (see instance-management.md)
- Deploy across multiple AZs
- Use Elastic Load Balancer for traffic distribution
- Implement health checks
Troubleshooting
Cannot SSH to Instance
First: identify the error type — it points to different root causes:
| Error | What it means | Primary suspects | |
|---|---|---|---|
Connection refused | Network is reachable, but SSH daemon is not listening | sshd crashed, sshd not installed, OS firewall (ufw/iptables) blocking, wrong port | |
Connection timed out | Packets never arrive | Security group blocks port 22, NACL blocks traffic, no public IP, wrong IP | |
Permission denied | Connected, but auth failed | Wrong key file, wrong username, key not authorized |
Common username by OS:
| OS | Default SSH user | |
|---|---|---|
| Amazon Linux 2 / 2023 | ec2-user | |
| Ubuntu | ubuntu | |
| Debian | admin | |
| CentOS / RHEL | ec2-user or centos | |
| Windows | Administrator |
Diagnostic commands:
If connection refused — get inside via Session Manager to fix sshd:
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/ec2/SKILL.md
Popularity
- Repository stars
- 1,064
- Repository forks
- 437
- 7-day trend score
- 35
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 8 Apr 2026, 6 months ago.
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/itsmostafa/aws-agent-skills/ec2)