0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

AWS CLIでCloudFrontのSSL証明書をIAM->ACMに切り替え

Posted at

あらすじ

・ 既存のCloudFrontに適用されているSSL証明書(iam)をACMに切り替えたかった
・ us-east-1での発行までは完了した
・ が、コンソール上で切り替えができず(プルダウン一覧に出てこない)、terraformの管理からも外れていた
・ CLIの出番やで

参考記事

検索力が足りずaws cliのドキュメントをうろうろしていたんですが、最終的に以下記事を読んで大枠が解決しました。ありがたい...
https://qiita.com/kooohei/items/c6dcf9dfee6abf693656

というわけで作業メモです。

対象のdistribution idや、変更前後の設定確認はコンソールとにらめっこしてやってしまったので確認系のコマンドは割愛。

aws-cli.sh
# 1.作業前confをファイルとして取得
aws cloudfront get-distribution-config --id "{ID}" | jq '.DistributionConfig' > {ID}.conf
# 2.confファイルの編集(後述)
vim {ID}.conf
# 3.変更用のETagを確認
aws cloudfront get-distribution-config --id "{ID}" | jq '.ETag'
# 4.編集後のconfファイル及び[3]で確認したETagを指定の上update
aws cloudfront update-distribution --id "{ID}" --distribution-config file://{ID}.conf --if-match {ETag}
# ~完~

2. の箇所、今回 {ID}.conf として取得したjsonファイルは以下の部分を書き換え

({ID}.conf)変更前-抜粋.json
"ViewerCertificate": {
    "SSLSupportMethod": "sni-only",
    "MinimumProtocolVersion": "TLSv1.1_2016",
    "IAMCertificateId": "XXXXXXXXXXXXXXXXXXXXX",
    "Certificate": "XXXXXXXXXXXXXXXXXXXXX",
    "CertificateSource": "iam"
},
({ID}.conf)変更後-抜粋.json
"ViewerCertificate": {
    "SSLSupportMethod": "sni-only",
    "MinimumProtocolVersion": "TLSv1.1_2016",
    "ACMCertificateArn": "arn:aws:acm:us-east-1:123456789012:certificate/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
    "Certificate": "arn:aws:acm:us-east-1:123456789012:certificate/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
    "CertificateSource": "acm"
},
0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?