AWS CLI throws "Unable to locate credentials", the second time it's run
Solution 1:
I had the same issue, even contacted support and they could not provide an answer. Exporting credentials to environmental variables does not work for aws s3 ...
commands. You have to either use the aws configure
util or create a ~/.aws/config
file like this one:
[default]
aws_access_key_id=foo
aws_secret_access_key=bar
region=us-west-2
Please reference AWS documentation at http://docs.aws.amazon.com/cli/latest/topic/config-vars.html
Not only did I find it failing to execute at all with the environment exports on EC2 launch via the User Data but also post launch from the command line on a fully deployed running instance.