If the aws command line utility is embedded inside the container then you can rewrite the commands like this.
environment:
- AWS_ACCESS_KEY_ID=$$(aws --profile default configure get aws_access_key_id)
- AWS_SECRET_ACCESS_KEY=$$(aws --profile default configure get aws_secret_access_key)
And if this aws
utility is on the host system then
you can set some environment variables on your shell like (.profile or .bashrc etc)
export HOST_ACCESS_KEY_ID=$(aws --profile default configure get aws_access_key_id)
export HOST_AWS_SECRET_ACCESS_KEY=$(aws --profile default configure get aws_secret_access_key)
and then reuse it in docker-compose.yml like
environment:
- AWS_ACCESS_KEY_ID=${HOST_ACCESS_KEY_ID}
- AWS_SECRET_ACCESS_KEY=${HOST_AWS_SECRET_ACCESS_KEY}