[Osaka/Yokohama] Looking for infrastructure/server side engineers!

[Osaka/Yokohama] Looking for infrastructure/server side engineers!

[Deployed by over 500 companies] AWS construction, operation, maintenance, and monitoring services

[Deployed by over 500 companies] AWS construction, operation, maintenance, and monitoring services

[Successor to CentOS] AlmaLinux OS server construction/migration service

[Successor to CentOS] AlmaLinux OS server construction/migration service

[For WordPress only] Cloud server “Web Speed”

[For WordPress only] Cloud server “Web Speed”

[Cheap] Website security automatic diagnosis “Quick Scanner”

[Cheap] Website security automatic diagnosis “Quick Scanner”

[Reservation system development] EDISONE customization development service

[Reservation system development] EDISONE customization development service

[Registration of 100 URLs is 0 yen] Website monitoring service “Appmill”

[Registration of 100 URLs is 0 yen] Website monitoring service “Appmill”

[Compatible with over 200 countries] Global eSIM “Beyond SIM”

[Compatible with over 200 countries] Global eSIM “Beyond SIM”

[If you are traveling, business trip, or stationed in China] Chinese SIM service “Choco SIM”

[If you are traveling, business trip, or stationed in China] Chinese SIM service “Choco SIM”

[Global exclusive service] Beyond's MSP in North America and China

[Global exclusive service] Beyond's MSP in North America and China

[YouTube] Beyond official channel “Biyomaru Channel”

[YouTube] Beyond official channel “Biyomaru Channel”

SSL証明書をAWSのELB上にアップロードする方法

SSL証明書をAWSのELB上にアップロードする方法

インフラチームの齊藤です。
インフラ、もしくは、社内SEのみなさん、SSL証明書更新毎度お疲れ様です。

さて、AWS Certificate Managerが今年5/16より東京リージョンで使用可能になりました。

これからはAmazonを認証局とするSSL証明書を無料で使用することができます。

ますます便利になっていくAWSですが、今回は別の認証局を通じて手に入れたSSL証明書をELBへ適用する方法をご紹介します。

作業にはAWSCLIを使用します。本作業を行う前に下記のモジュールをインストールしてください。

pip install awscli

初期設定がお済みでない場合には下記のコマンドを入力後

aws configure

下記項目を入力することで、デフォルトの設定を完了します。
AWS Access Key ID [None]:
AWS Secret Access Key [None]:
Default region name [None]:
Default output format [None]:

設定した内容は、~/.aws/credentials, ~/.aws/configというファイル名で保存されています。

アップロード方法

まずはSSL証明書を用意します。awscliコマンドが打てる環境にて
SSL証明書をカレントディレクトリに用意していただき、
下記コマンドでSSL証明書をリモートのマネジメントコンソール上へアップロードしてください。

aws iam upload-server-certificate --server-certificate-name "example-domain.com" \
--certificate-body file://./example-domain.com.crt \
--private-key file://./example-domain.com.key \
--certificate-chain file://./example-domain.com.ca

それぞれ、
certificate-body:サーバ証明書
private-key:秘密鍵を指定
certificate-chain:中間証明書
を指定します。

~/.aws/credentials内に複数のユーザ情報が入っている方は、--profileオプションで指定してください。
また、リージョンを指定するようにエラーが出力された場合には、--regionオプションでELBのリージョンを指定します。
例えば、東京リージョンならap-northeast-1です。

それでは、事例別にコマンドを列挙します。

ELBに新たにhttps(443)→http(80)のようなリスナーを追加する場合

aws elb create-load-balancer-listeners \
--load-balancer-name \
--listeners Protocol=HTTPS,LoadBalancerPort=443,InstanceProtocol=HTTP,InstancePort=80,SSLCertificateId=arn:iam:::server-certificate/example-domain.com
--region ap-northeast-1

既にあるリスナーの証明書を更新する場合

aws elb set-load-balancer-listener-ssl-certificate \
--load-balancer-name \
--load-balancer-port 443 \
--ssl-certificate-id arn:aws:iam:::server-certificate/example-domain.com \
--region ap-northeast-1

アップロードした証明書を削除する場合

aws iam delete-server-certificate --server-certificate-name example-domain.com

リスナーを削除する場合

aws elb delete-load-balancer-listeners --load-balancer-name --load-balancer-ports 443

以上のコマンドを知っておくことで、ELBへの証明書のアップロード作業がよりスムーズになりました。
定形処理としてシェルスクリプトに埋め込んでおくのもいいですね。

この記事がお役に立てば【 いいね 】のご協力をお願いいたします!
0
読み込み中...
0 票, 平均: 0.00 / 10
568
X facebook はてなブックマーク pocket
[2024.6.30 CentOS support ended] CentOS server migration solution

[2024.6.30 CentOS support ended] CentOS server migration solution

[2025.6.30 Amazon Linux 2 support ended] Amazon Linux server migration solution

[2025.6.30 Amazon Linux 2 support ended] Amazon Linux server migration solution

[Osaka/Yokohama] Actively recruiting infrastructure engineers and server side engineers!

[Osaka/Yokohama] Actively recruiting infrastructure engineers and server side engineers!

The person who wrote this article

About the author