Reputation: 15384
As part of the process to build my docker container I need to pull some files from an s3 bucket but I keep getting fatal error: Unable to locate credentials
even though for now I am setting the credentials as ENV
vars (though would like to know of a better way to do this)
So when building the container I run
docker build -t my-container --build-arg AWS_DEFAULT_REGION="region" --build-arg AWS_ACCESS_KEY="key" --build-arg AWS_SECRET_ACCESS_KEY="key" . --squash
And in my Dockerfile I have
ARG AWS_DEFAULT_REGION
ENV AWS_DEFAULT_REGION=$AWS_DEFAULT_REGION
ARG AWS_ACCESS_KEY
ENV AWS_ACCESS_KEY=$AWS_ACCESS_KEY
ARG AWS_SECRET_ACCESS_KEY
ENV AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY
RUN /bin/bash -l -c "aws s3 cp s3://path/to/folder/ /my/folder --recursive"
Does anyone know how I can solve this (I know there is an option to add a config file but that just seems an unnecessary extra step as I should be able to read from ENV).
Upvotes: 14
Views: 15492
Reputation: 53793
The name of the environment variable is AWS_ACCESS_KEY_ID
vs AWS_ACCESS_KEY
You can review the full list from amazon doc
The following variables are supported by the AWS CLI
AWS_ACCESS_KEY_ID
– AWS access key.
AWS_SECRET_ACCESS_KEY
– AWS secret key. Access and secret key variables override credentials stored in credential and config files.
AWS_SESSION_TOKEN
– session token. A session token is only required if you are using temporary security credentials.
AWS_DEFAULT_REGION
– AWS region. This variable overrides the default region of the in-use profile, if set.
AWS_DEFAULT_PROFILE
– name of the CLI profile to use. This can be the name of a profile stored in a credential or config file, or default to use the default profile.
AWS_CONFIG_FILE
– path to a CLI config file.
Upvotes: 11