ec2でaws s3 cp を実行すると Unable to locate credentials エラー
pg_dumpした.sql形式のバックアップファイルをS3にコピーするシェルを起動したら、以下のエラーが発生した。
upload failed: db_backup/db_schema_20240215_014303.sql to s3://bucket-name/db_schema_20240215_014303.sql Unable to locate credentials
AWS認証情報が設定されていない?
code: ec2$
$ aws configure list
Name Value Type Location
---- ----- ---- --------
profile <not set> None None
access_key <not set> None None
secret_key <not set> None None
region <not set> None None
やはり。
環境変数で設定する。
code: .bash_profile
export AWS_ACCESS_KEY_ID=**********
export AWS_SECRET_ACCESS_KEY=**********
export AWS_DEFAULT_REGION=ap-northeast-1
反映して確認。
$ source ~/.bash_profile
$ export -p
確認。
code: ec2$
$ aws configure list
Name Value Type Location
---- ----- ---- --------
profile <not set> None None
access_key ******************** env
secret_key ******************** env
region ap-northeast-1 env AWS_DEFAULT_REGION
これでシェルの実行&S3へのアップロードもOK。
#aws #s3 #postgresl #pg_dump