概要
CircleCIで環境変数やContextsに値を設定しても、AWS CLIが以下のようなエラーで落ちることがあります。
#!/bin/bash -eo pipefail
aws configure set aws_access_key_id \
$AWS_ACCESS_KEY_ID \
--profile default
usage: aws [options] <command> <subcommand> [<subcommand> ...] [parameters]
To see help text, you can run:
aws help
aws <command> help
aws <command> <subcommand> help
aws: error: the following arguments are required: value
Exited with code 2
原因
- GitHubのフォークしたリポジトリからPRを出している
- そしてCircleCIの
Advanced Settings
のPass secrets to builds from forked pull requests
がOff
になっている
- そしてCircleCIの
対策
上記の設定をOn
にすれば解決するが、脆弱性の懸念が大きいためおすすめできません。(詳しくは設定画面の説明を参照)
Pass secrets to builds from forked pull requests
Run builds for fork pull request changes with this project's configuration, environment variables, and secrets.There are serious security concerns with this setting (see the documentation for details.) If you have SSH keys, sensitive env vars or AWS credentials stored in your project settings and untrusted forks can make pull requests against your repo, then this option isn't for you!
各自でビルドを行わないのであればフォークしない運用とするのが良いと思われます。