環境
> aws --version
aws-cli/2.15.0 Python/3.11.6 Windows/10 exe/AMD64 prompt/off
事象
AWS Certificate Manager(ACM)にて外部で発行した証明書をCLIでインポートするため以下のコマンドを実行したところ、エラーが発生しました。
# 実行コマンド
> aws acm import-certificate
--certificate file://xxxx.cer
--private-key file://xxxx.key
--certificate-chain file://xxxx.txt
# 発生したエラー
An error occurred (ValidationException) when calling the ImportCertificate operation:
The certificate field contains more than one certificate.
You can specify only one certificate in this field.
対処方法
ファイルの指定時に「file://」ではなく「fileb://」とすることで正常にインポートできました。
# 実行コマンド
> aws acm import-certificate
--certificate fileb://xxxx.cer
--private-key fileb://xxxx.key
--certificate-chain fileb://xxxx.txt
詳細
「file://」は、base64エンコードされたテキスト情報を渡す際に使用するようです。
参考
Command line options in the AWS CLI
真のバイナリコンテンツを渡すには、コンテンツをファイルに置き、ファイルのパスと名前をパラメータの値として fileb:// プレフィックスを付けて指定します。ファイルに含まれる base64 エンコードされたテキストを渡すには、ファイルのパスと名前をパラメータの値として file:// プレフィックスを付けて指定します。