March 2025
Intermediate to advanced
358 pages
5h 26m
Japanese
これらの便利なちょっとしたコードは、、時間を節約し、AWSを最大限に活用するのに役立つだろう。
AWS_ACCOUNT_ID をbash変数にセットする:
export AWS_ACCOUNT_ID=$(aws sts get-caller-identity \ --query Account --output text)
最近作成されたCloudWatchロググループ名を取得する:
aws logs describe-log-groups --output=yaml \
--query 'reverse(sort_by(logGroups,&creationTime))[:1].{Name:logGroupName}'
CloudWatchグループのログを :
aws logs tail <<LOGGROUPNAME>> --follow --since 10s
テキストパターンにマッチするすべてのロググループを削除し、確認のため yes/no を prompt する:
aws logs describe-log-groups | \ jq ".logGroups[].logGroupName" | grep -i <<pattern>> | \ xargs -p -I % aws logs delete-log-group --log-group-name %
現在作業しているリージョンについて、実行中のインスタンスをすべて停止する(H/T: Curtis Rissi):
aws ec2 stop-instances \ --instance-ids $(aws ec2 describe-instances \ --filters "Name=instance-state-name,Values=running" --query "Reservations[].Instances[].[InstanceId]" --output text | tr '\n' ' ')
CLI呼び出しを行うユーザを決定する:
aws sts get-caller-identity --query UserId --output text
、CLIコマンド、YAML入力を生成して使う:
aws ec2 create-vpc --generate-cli-skeleton yaml-input > input.yaml #Edit input.yaml - at a minimum modify CidrBlock, DryRun, ResourceType, and Tags aws ec2 create-vpc --cli-input-yaml file://input.yaml
AWSリージョンの名前 とエンドポイントを表形式でリストアップする:
aws ec2 describe-regions --output table
現在使用している Region のインタフェース VPC エンドポイント を発見する:
aws ec2 describe-vpc-endpoint-services \ --query ServiceDetails[*].ServiceName
のデータを DynamoDB テーブルに投入する:
aws ddb put table_name '[{key1: value1}, {key2: value2}]'
特定のデータベースエンジン(例:aurora-postgresql)で現在サポートされている ...