aws-requests-auth icon indicating copy to clipboard operation
aws-requests-auth copied to clipboard

Add ability to pass parameters to the botocore session.

Open dashstander opened this issue 5 years ago • 4 comments

Adds session_params parameter to BotoAwsRequestsAuth that gets unpacked into the botocore session object. This allows things like passing in regions, profiles, etc... that are outside the default way botocore picks credentials. Solves #51

dashstander avatar Jan 03 '20 02:01 dashstander

Would benefit from this getting merged and released at some point. What is left? I think I like using kwarg aws_profile instead of just profile to follow pattern already there (and AWS ENV var nomenclature).

hekaldama avatar Feb 07 '20 19:02 hekaldama

I do not have plans for a new release soon - my company has stopped using this package. In the meantime, a workaround is to use the get_aws_request_headers_handler hook exposed by AWSRequestsAuth to execute arbitrary code for credential fetching. (Indeed, this is what BotoAWSRequestsAuth does internally.)

class MyAuth(AWSRequestsAuth):

    def get_aws_request_headers_handler(self, r):
        return self.get_aws_request_headers(
            r=r,
            aws_access_key=# any code you like,
            aws_secret_access_key=# any code you like,
            aws_token=# any code you like,
         )

DavidMuller avatar Feb 07 '20 20:02 DavidMuller

Sounds good and thanks @DavidMuller. If anyone else is looking into this I also did AWS_REGION on the env to get this to work.

hekaldama avatar Feb 07 '20 20:02 hekaldama

@ethan-deng Will this be merged if you've approved it? seems like a helpful addition

clayrosenthal avatar Jun 22 '22 23:06 clayrosenthal