AWS CLI¶
About¶
https://github.com/aws/aws-cli
NOTE:
- 2020-02-12 AWS CLI v2が一般利用可能になった。
Install¶
macOS¶
※2020-06-03 Homebrewでv2が入るが、なぜかpythonに依存している。
https://formulae.brew.sh/formula/awscli
Dockerイメージ¶
※過去の記述である
https://hub.docker.com/r/mesosphere/aws-cli/ がちゃんとしてそう。
Reference¶
※以下、古いWikiの内容をマイグレートしたので、v1の情報が元になっているものが多い。
configure¶
参考:
ecs¶
https://awscli.amazonaws.com/v2/documentation/api/latest/reference/ecs/
update-service¶
https://awscli.amazonaws.com/v2/documentation/api/latest/reference/ecs/update-service.html
Examples:
# タスク定義を更新
aws ecs update-service --cluster $CLUSTER --service $SERVICE --task-definition $TASK_DEFINITION
# サービス定義を更新せずに再起動
aws ecs update-service --cluster $CLUSTER --service $SERVICE --force-new-deployment
logs¶
http://docs.aws.amazon.com/cli/latest/reference/logs/index.html
CloudWatch Logs.
- http://docs.aws.amazon.com/cli/latest/reference/logs/get-log-events.html
--start-time,--end-timeの引数はミリ秒単位のunixtime--limitは10000が上限で、より大きな値を指定するとバリデーションエラーになる。
Examples:
# 2017/12/20 8:50 - 9:10のログを取得
$ date +%s -d "2017-12-20 08:50:00"
1513727400
$ date +%s -d "2017-12-20 09:10:00"
1513728600
$ aws logs get-log-events \
--log-group-name <your-log-group> --log-stream-name <your-log-stream> \
--start-time 1513727400000 --end-time 1513728600000 [--output text]
create-log-group¶
https://awscli.amazonaws.com/v2/documentation/api/latest/reference/logs/create-log-group.html
describe-log-groups¶
https://awscli.amazonaws.com/v2/documentation/api/latest/reference/logs/describe-log-groups.html
sns¶
Examples:
# テキストファイルの内容を送信
aws sns publish --topic-arn "arn:aws:sns:ap-northeast-1:${AWS_ACCOUNT_ID}:${topic}" --subject "my sns notification" --message file://path/to/message-file
# コマンドの実行結果を送信
aws sns publish --topic-arn "arn:aws:sns:ap-northeast-1:${AWS_ACCOUNT_ID}:${topic}" --message "$(cat path/to/file)"
ssm¶
http://docs.aws.amazon.com/cli/latest/reference/ssm/index.html
Parameter Store:
- http://docs.aws.amazon.com/cli/latest/reference/ssm/get-parameter.html
- http://docs.aws.amazon.com/cli/latest/reference/ssm/get-parameters.html
- http://docs.aws.amazon.com/cli/latest/reference/ssm/put-parameter.html
sts¶
SYNOPSIS:
参考: