If I just define AWS_SECRET_KEY,AWS_ACCESS_KEY in my bash env,
I get the following error with all ec2 modules.
boto.exception.EC2ResponseError: EC2ResponseError: 401 Unauthorized
<?xml version="1.0" encoding="UTF-8"?>
<Response><Errors><Error><Code>AuthFailure</Code><Message>AWS was not able to validate the provided access credentials</Message></Error></Errors><RequestID>9ad65772-2754-42ab-901b-ef9153276797</RequestID></Response>
If I add the aws_access_key and aws_secret_key and lookup the var, I get the same error unless I rstrip('\\r') . I discovered the trailing '\r' by running with -vvvv .
group_vars/all
aws_secret_key: "{{lookup('env','AWS_SECRET_KEY').rstrip('\\r')}}"
aws_access_key: "{{lookup('env','AWS_ACCESS_KEY').rstrip('\\r')}}"
task I am running.