mcpField
A
aws-cli

aws-cli

github.com/oldwinterクラウド・DevOps10135 回インストール1 週間前に更新
リポジトリ

aws-cli について

aws-cli は、AWS CLI で AWS インフラを管理するためのスキルです。一般的なクラウドサービスを扱う運用担当者向けに、コマンド例、出力方法、エラー対応、高リスク操作の確認手順をまとめています。

主な機能

  1. 01AWS の計算、ストレージ、DB、ネットワークのコマンド例
  2. 02監視、請求、Bedrock、サポート、IAM の例
  3. 03高リスク操作の確認手順
  4. 04クエリ形式とエラー対応のガイド

活用シーン

  1. 01EC2、ECS、EKS リソースの確認
  2. 02S3、RDS、DynamoDB リソースの管理
  3. 03AWS の費用や CloudWatch ログの確認
  4. 04IAM の ID と関連リソースの確認

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/oldwinter/skills --skill aws-cli

インストール後、Claude Code で/aws-cliを入力して読み込まれたか確認します。

同梱ファイル

SKILL.md と一緒にインストールされる参考資料やスクリプト。

references/
jmespath_queries.md
troubleshooting.md
scripts/
ecr_compare.py
resource_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 コマンドが失敗した場合:

  1. エラーメッセージを解析して問題を特定します
  2. 考えられる解決策を提案します
  3. アクセスが拒否された場合は IAM 権限を確認します
  4. リソースが存在し、正しいリージョンにあることを確認します

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)

コメント