LoginSignup
3
0

More than 3 years have passed since last update.

AWS CLI 2.1.28 で 'ascii' codec can't encode characters

Posted at

CodeBuild から AWS CLI の aws lambda update-function-code を実行したら、2 バイト文字に関するエラーがでました。

AWS CLI のバージョン 2.1.28 で発生しており、一つ前の 2.1.27 では発生していませんでした。

aws --version
aws-cli/2.1.28 Python/3.8.8 Linux/4.14.214-118.339.amzn1.x86_64 exec-env/AWS_ECS_EC2 exe/x86_64.amzn.2 prompt/off
aws lambda update-function-code --function-name $LAMBDA_FUNCTION_NAME --image-uri $REPOSITORY_URI:$CODEBUILD_RESOLVED_SOURCE_VERSION
{
    "FunctionName": "abcdefg",
    "FunctionArn": "arn:aws:lambda:ap-northeast-1:000000000000:function:abcdefg",
    "Role": "arn:aws:iam::000000000000:role/abcdefg",
    "CodeSize": 0,
    "Description": 
'ascii' codec can't encode characters in position 1-11: ordinal not in range(128)

Description には、日本語を入れているので、その扱いがうまくいってない様子。

差分をみてみると、依存する Python が 3.8 に変わったようです。
https://github.com/aws/aws-cli/compare/2.1.27...2.1.28

環境変数 Lang や PYTHONIOENCODING を設定してみたものの、効果なし。

export LANG=ja_JP.UTF-8
export PYTHONIOENCODING=utf-8

AWS CLI が今後対処してくれるかもしれないのと、この AWS CLI コマンドの出力に重要なものがなかったことから、--query オプションを追加して、Description を出力しないように回避しました。

aws lambda update-function-code --function-name $LAMBDA_FUNCTION_NAME --image-uri $REPOSITORY_URI:$CODEBUILD_RESOLVED_SOURCE_VERSION --query 'Configuration.{LastModified:LastModified}'
3
0
1

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
3
0