algo/tests/aws-credentials.sh
Dan Zwell ae6bdc916c Read AWS credentials from disk (#14382)
Other programs can read the AWS key and secret from ~/.aws/credentials
(or other configuration file), and with this change Algo can as well.

Optional environment variables: AWS_PROFILE, AWS_SHARED_CREDENTIALS_FILE

The file is not read if the credentials are already set as an Ansible
variable or an environment variable.
2022-04-05 19:03:12 +08:00

24 lines
882 B
Bash
Executable file

#!/usr/bin/env bash
# command line credentials should still work:
ansible-playbook tests/validate-aws-credentials.yml \
-e aws_access_key=example_key \
-e aws_secret_key=example_secret
# command line credentials should override config files:
ansible-playbook tests/validate-aws-credentials.yml \
-e aws_access_key=example_key \
-e aws_secret_key=example_secret
# In this case the config file is bad but the command line should win:
AWS_SHARED_CREDENTIALS_FILE="$PWD/tests/.aws/credentials2" \
ansible-playbook tests/validate-aws-credentials.yml \
-e aws_access_key=example_key \
-e aws_secret_key=example_secret
# should read from the config file in tests/.aws:
HOME="$PWD/tests" \
ansible-playbook tests/validate-aws-credentials.yml
AWS_SHARED_CREDENTIALS_FILE="$PWD/tests/.aws/credentials2" AWS_PROFILE=profile1 \
ansible-playbook tests/validate-aws-credentials.yml