跳到正文
Skillpedia
部署与云(DevOps)48k · #3858

aws-ec2

它能做什么

这个工具可以帮你在亚马逊云(AWS)上创建和管理虚拟计算机,也就是 EC2 实例。你可以设置这些计算机的运行方式、需要的数量,以及它们之间如何通信。

适用场景

  • ✓当你需要一台服务器来运行网站或应用时。
  • ✓当你想快速部署,需要创建完全相同的服务器副本时。
  • ✓当你希望根据需求自动增减服务器数量时。

技能链接

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/aws-ec2/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/aws-ec2/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“创建一台用来运行电商网站的服务器,配置 2 个 CPU 和 8GB 内存,并设置为当 CPU 使用率超过 70% 时自动扩容。”

每周 5 个新技能,1 分钟读完。

工作原理

你需要使用特定的命令告诉 AWS 要创建什么,比如计算机类型(实例)、操作系统(AMI)和安全规则。之后 AWS 会帮你把一切设置好。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

AWS EC2

Deploy and manage Amazon EC2 compute instances for production, staging, and development workloads.

When to Use This Skill

  • Launching new compute instances for application hosting
  • Building golden AMIs for consistent deployments
  • Setting up auto-scaling groups behind load balancers
  • Migrating workloads to Spot instances for cost savings
  • Troubleshooting instance connectivity, performance, or launch failures
  • Creating launch templates for repeatable infrastructure

Prerequisites

  • AWS CLI v2 installed and configured (aws configure)
  • IAM permissions: ec2:*, autoscaling:*, elasticloadbalancing:*, iam:PassRole
  • An existing VPC with subnets (see aws-vpc (aws-vpc))
  • SSH key pair created (aws ec2 create-key-pair --key-name my-key --query 'KeyMaterial' --output text > my-key.pem)

Instance Type Selection Guide

Category Types Use Case
General Purpose t3, t3a, m6i, m7g Web servers, small databases, dev/test
Compute Optimized c6i, c7g Batch processing, media encoding, ML inference
Memory Optimized r6i, r7g, x2idn In-memory caches, large databases
Storage Optimized i3, i4i, d3 Data warehousing, distributed file systems
Accelerated p4d, g5, inf2 ML training, GPU rendering, inference
Burstable t3.micro-t3.2xlarge Low-steady-state with occasional bursts

Launch an Instance

# Launch a production web server
aws ec2 run-instances \
  --image-id ami-0abcdef1234567890 \
  --instance-type t3.medium \
  --key-name my-key \
  --security-group-ids sg-12345678 \
  --subnet-id subnet-12345678 \
  --iam-instance-profile Name=EC2AppProfile \
  --metadata-options "HttpTokens=required,HttpEndpoint=enabled" \
  --block-device-mappings '[{
    "DeviceName": "/dev/xvda",
    "Ebs": {
      "VolumeSize": 30,
      "VolumeType": "gp3",
      "Iops": 3000,
      "Throughput": 125,
      "Encrypted": true
    }
  }]' \
  --tag-specifications 'ResourceType=instance,Tags=[
    {Key=Name,Value=web-server-01},
    {Key=Environment,Value=production},
    {Key=Team,Value=platform}
  ]' \
  --user-data file://userdata.sh

# Launch with IMDSv2 required (security best practice)
aws ec2 run-instances \
  --image-id ami-0abcdef1234567890 \
  --instance-type t3.micro \
  --metadata-options "HttpTokens=required,HttpPutResponseHopLimit=1,HttpEndpoint=enabled" \
  --tag-specifications 'ResourceType=instance,Tags=[{Key=Name,Value=secure-instance}]'

User Data Scripts

#!/bin/bash
# userdata.sh - Bootstrap a web server on Amazon Linux 2023
set -euxo pipefail

# System updates
dnf update -y

# Install and start web server
dnf install -y nginx
systemctl enable nginx
systemctl start nginx

# Install CloudWatch agent
dnf install -y amazon-cloudwatch-agent
/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl \
  -a fetch-config -m ec2 \
  -s -c ssm:AmazonCloudWatch-linux

# Install CodeDeploy agent
dnf install -y ruby wget
cd /home/ec2-user
wget https://aws-codedeploy-us-east-1.s3.us-east-1.amazonaws.com/latest/install
chmod +x ./install
./install auto

# Signal CloudFormation (if launched via CFN)
# /opt/aws/bin/cfn-signal -e $? --stack ${AWS::StackName} --resource ASG --region ${AWS::Region}

Launch Templates

# Create a launch template with full configuration
aws ec2 create-launch-template \
  --launch-template-name web-server-template \
  --version-description "v1 - AL2023 with nginx" \
  --launch-template-data '{
    "ImageId": "ami-0abcdef1234567890",
    "InstanceType": "t3.medium",
    "KeyName": "my-key",
    "SecurityGroupIds": ["sg-12345678"],
    "IamInstanceProfile": {"Name": "EC2AppProfile"},
    "MetadataOptions": {
      "HttpTokens": "required",
      "HttpEndpoint": "enabled"
    },
    "BlockDeviceMappings": [{
      "DeviceName": "/dev/xvda",
      "Ebs": {
        "VolumeSize": 30,
        "VolumeType": "gp3",
        "Encrypted": true
      }
    }],
    "TagSpecifications": [{
      "ResourceType": "instance",
      "Tags": [
        {"Key": "Environment", "Value": "production"},
        {"Key": "ManagedBy", "Value": "launch-template"}
      ]
    }],
    "Monitoring": {"Enabled": true},
    "UserData": "'"$(base64 -w0 userdata.sh)"'"
  }'

# Create a new version of the launch template
aws ec2 create-launch-template-version \
  --launch-template-name web-server-template \
  --source-version 1 \
  --version-description "v2 - updated AMI" \

…
常见问题

什么是 EC2 实例?

它是 Amazon Web Services(AWS)云中的一台虚拟服务器,你可以用它来运行自己的应用。

什么是 AMI?

它是操作系统和预装软件的模板或镜像,你可以用它来创建新的 EC2 实例。

什么是自动伸缩组?

它是一套能根据需要自动增加或减少服务器(EC2 实例)数量的系统,以确保你的应用平稳运行、不中断。

详情

作者的原始描述

Manage EC2 instances, AMIs, and auto-scaling groups. Configure security groups, key pairs, and instance types. Use when deploying compute resources on AWS.

repo: sickn33/agentic-awesome-skills

热度

GitHub 星标
48k
排名
#3858
许可证
MIT
更新时间
2026/10/15

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能