手順
3つのコマンドを実行して達成可能。
- CloudFront の disutribution id を入手
- パスを無効化する
- 無効化の進捗状況を確認する
例の内訳
- {profile}
- 認証情報のプロファイル
- {hostname}
- ドメイン割り当て済みならFQDN
- {path}
- 無効化するパス。例えば
/aaa/bbb.json
例
$ aws cloudfront list-distributions --profile {profile} | jq '.DistributionList.Items[] | .Id + " " + .Aliases.Items[0]' -r
E************ {hostname}
...
$ aws cloudfront create-invalidation --distribution-id E************ --paths "{path}" --profile {profile}
{
"Location": "https://cloudfront.amazonaws.com/2020-05-31/distribution/E************/invalidation/I17***********",
"Invalidation": {
"Id": "I17***********",
"Status": "InProgress",
"CreateTime": "2021-02-22T12:47:09.866Z",
"InvalidationBatch": {
"Paths": {
"Quantity": 1,
"Items": [
"{path}"
]
},
"CallerReference": "cli-0000000000-000000"
}
}
}
$ aws cloudfront get-invalidation --id I17*********** --distribution-id E************ --profile {profile} | jq -r '.Invalidation | .CreateTime + " " + .Status'
2021-02-22T12:47:09.866Z Completed
$ aws cloudfront get-invalidation --id I17*********** --distribution-id E************ --profile {profile}
{
"Invalidation": {
"Id": "I17***********",
"Status": "Completed",
"CreateTime": "2021-02-22T12:47:09.866Z",
"InvalidationBatch": {
"Paths": {
"Quantity": 1,
"Items": [
"{path}"
]
},
"CallerReference": "cli-0000000000-000000"
}
}
}