关于 aws-cli
aws-cli 是通过 AWS CLI 管理 AWS 基础设施的技能,面向处理常见云服务的运维人员。它提供命令参考、输出指引、错误处理,以及针对高风险操作的确认规则。
主要功能
- 01AWS 计算、存储、数据库和网络命令参考
- 02监控、账单、Bedrock、支持和 IAM 示例
- 03高风险操作的确认规则
- 04查询格式与错误处理指引
适用场景
- 01检查 EC2、ECS 和 EKS 资源
- 02管理 S3、RDS 和 DynamoDB 资源
- 03查看 AWS 费用与 CloudWatch 日志
- 04检查 IAM 身份及相关资源
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ oldwinter/ skills --skill aws-cli安装后在 Claude Code 中输入/aws-cli确认已加载。
包含的文件
除 SKILL.md 外,安装时一起下载的参考资料和脚本。
references/jmespath_queries.mdtroubleshooting.mdscripts/ecr_compare.pyresource_summary.py详细介绍
AWS CLI 技能
此技能可通过 AWS CLI 工具全面管理 AWS 云基础设施。
环境
- 默认区域:
us-east-1 - AWS CLI:已预配置完整账户权限
- 账户:SimplexAI AWS 账户(ID:830101142436)
安全协议
需要确认的危险操作
执行以下任何操作之前,请明确向用户确认:
- 删除操作:
delete-*、remove-*、terminate-*、deregister-* - 破坏性修改:对生产资源执行
modify-*,或执行会更改关键设置的update-* - 状态更改:对生产实例执行
stop-*、reboot-* - 安全更改:IAM 策略修改、安全组规则更改
- 成本影响:创建高成本资源(大型 EC2 实例、NAT 网关等)
确认格式
⚠️ 危险操作确认
操作: [具体操作描述]
影响: [潜在影响说明]
资源: [受影响的资源标识]
是否继续执行?
常见操作参考
计算服务
EC2
# List instances
aws ec2 describe-instances --query 'Reservations[].Instances[].[InstanceId,State.Name,InstanceType,Tags[?Key==`Name`].Value|[0]]' --output table
# Instance state management
aws ec2 start-instances --instance-ids <id>
aws ec2 stop-instances --instance-ids <id>
aws ec2 reboot-instances --instance-ids <id>
ECS
# List clusters and services
aws ecs list-clusters
aws ecs list-services --cluster <cluster-name>
aws ecs describe-services --cluster <cluster-name> --services <service-name>
# View running tasks
aws ecs list-tasks --cluster <cluster-name> --service-name <service-name>
aws ecs describe-tasks --cluster <cluster-name> --tasks <task-arn>
# Force new deployment
aws ecs update-service --cluster <cluster-name> --service <service-name> --force-new-deployment
EKS
# List clusters
aws eks list-clusters
aws eks describe-cluster --name <cluster-name>
# Update kubeconfig
aws eks update-kubeconfig --name <cluster-name> --region us-east-1
Lambda
# List functions
aws lambda list-functions --query 'Functions[].[FunctionName,Runtime,LastModified]' --output table
# Invoke function
aws lambda invoke --function-name <name> --payload '{}' response.json
# View logs
aws logs tail /aws/lambda/<function-name> --follow
存储服务
S3
# List buckets and objects
aws s3 ls
aws s3 ls s3://<bucket-name>/ --recursive --human-readable
# Copy and sync
aws s3 cp <local-file> s3://<bucket>/<key>
aws s3 sync <local-dir> s3://<bucket>/<prefix>
# Bucket info
aws s3api get-bucket-location --bucket <bucket-name>
aws s3api get-bucket-versioning --bucket <bucket-name>
ECR
# List repositories
aws ecr describe-repositories --query 'repositories[].[repositoryName,repositoryUri]' --output table
# List images in repository
aws ecr describe-images --repository-name simplexai/<service> --query 'imageDetails | sort_by(@, &imagePushedAt) | [-10:].[imageTags[0],imagePushedAt]' --output table
# Get login token
aws ecr get-login-password --region us-east-1
数据库服务
RDS
# List instances
aws rds describe-db-instances --query 'DBInstances[].[DBInstanceIdentifier,DBInstanceClass,Engine,DBInstanceStatus]' --output table
# Instance details
aws rds describe-db-instances --db-instance-identifier <id>
# Snapshots
aws rds describe-db-snapshots --db-instance-identifier <id>
DynamoDB
# List tables
aws dynamodb list-tables
# Table info
aws dynamodb describe-table --table-name <table>
# Query/scan
aws dynamodb scan --table-name <table> --limit 10
ElastiCache
# List clusters
aws elasticache describe-cache-clusters
aws elasticache describe-replication-groups
网络服务
VPC
# List VPCs and subnets
aws ec2 describe-vpcs --query 'Vpcs[].[VpcId,CidrBlock,Tags[?Key==`Name`].Value|[0]]' --output table
aws ec2 describe-subnets --query 'Subnets[].[SubnetId,VpcId,CidrBlock,AvailabilityZone]' --output table
# Security groups
aws ec2 describe-security-groups --query 'SecurityGroups[].[GroupId,GroupName,VpcId]' --output table
Route53
# List hosted zones
aws route53 list-hosted-zones
# List records
aws route53 list-resource-record-sets --hosted-zone-id <zone-id>
CloudFront
# List distributions
aws cloudfront list-distributions --query 'DistributionList.Items[].[Id,DomainName,Status]' --output table
# Invalidate cache
aws cloudfront create-invalidation --distribution-id <id> --paths "/*"
监控与日志
CloudWatch
# List log groups
aws logs describe-log-groups --query 'logGroups[].[logGroupName,storedBytes]' --output table
# Tail logs
aws logs tail <log-group-name> --follow --since 1h
# Get metrics
aws cloudwatch get-metric-statistics \
--namespace AWS/EC2 \
--metric-name CPUUtilization \
--dimensions Name=InstanceId,Value=<instance-id> \
--start-time $(date -u -v-1H +%Y-%m-%dT%H:%M:%SZ) \
--end-time $(date -u +%Y-%m-%dT%H:%M:%SZ) \
--period 300 \
--statistics Average
成本与账单
# Get current month costs
aws ce get-cost-and-usage \
--time-period Start=$(date +%Y-%m-01),End=$(date +%Y-%m-%d) \
--granularity MONTHLY \
--metrics BlendedCost \
--group-by Type=DIMENSION,Key=SERVICE
# Cost by service
aws ce get-cost-and-usage \
--time-period Start=$(date +%Y-%m-01),End=$(date +%Y-%m-%d) \
--granularity DAILY \
--metrics UnblendedCost \
--group-by Type=DIMENSION,Key=SERVICE
AI 服务(Bedrock)
# List models
aws bedrock list-foundation-models --query 'modelSummaries[].[modelId,providerName]' --output table
# List custom models
aws bedrock list-custom-models
支持
# Create support case
aws support create-case \
--subject "Issue description" \
--communication-body "Detailed description" \
--service-code amazon-ec2 \
--category-code general-info \
--severity-code low
# List cases
aws support describe-cases
IAM
# List users and roles
aws iam list-users --query 'Users[].[UserName,CreateDate]' --output table
aws iam list-roles --query 'Roles[].[RoleName,CreateDate]' --output table
# Get current identity
aws sts get-caller-identity
输出格式指南
查询操作
- 使用
--query和 JMESPath 筛选相关字段 - 使用
--output table输出便于阅读的结果 - 需要详细数据时使用
--output json
状态检查
提供简明摘要:
✅ EC2 实例状态
┌─────────────────┬──────────┬────────────┐
│ 实例 ID │ 状态 │ 类型 │
├─────────────────┼──────────┼────────────┤
│ i-0abc123... │ running │ t3.medium │
└─────────────────┴──────────┴────────────┘
修改操作
报告已执行的操作及结果:
✅ 操作完成
- 操作: 停止 EC2 实例
- 实例: i-0abc123def456
- 之前状态: running
- 当前状态: stopping
错误处理
AWS CLI 命令失败时:
- 解析错误消息以确定问题
- 提出可能的解决方案
- 如果访问被拒绝,检查 IAM 权限
- 确认资源存在且位于正确区域
与 GitOps 集成
此技能与 SimplexAI GitOps 工作流集成:
- ECR 注册表:
830101142436.dkr.ecr.us-east-1.amazonaws.com/simplexai/* - EKS 集群:us-east-1 中的生产和预发布环境
- 命名空间:生产环境使用
production,预发布环境使用staging
有关 kubectl 集群别名,请参阅 CLAUDE.md:
k1- AWS 生产环境(EKS)k2- AWS 预发布环境(EKS)
评论
支持 Markdown