jegesh / python-sqs-listener

A simple wrapper for boto3 for listening, and sending, to an AWS SQS queue
Other
154 stars 72 forks source link

Allow use of separate AWS credentials #33

Closed acidbotmaker closed 2 years ago

acidbotmaker commented 5 years ago

Is it possible to add feature to use aws credentials from either .env file or in constructor?

raminsj13 commented 4 years ago

perhaps via the "profile" parameter in botocore/session.py?

jegesh commented 4 years ago

A PR would be awesome if this is still an issue! (if not please close)

jegesh commented 4 years ago

Btw if you have the AWS credentials in an .env file you can just source it before you run the listener itself: source .env && python listener.py

jegesh commented 4 years ago

@raminsj13 since the listener relies on boto for resolving credentials, just setting the AWS_PROFILE environment variable should allow you to choose the profile you want to use for the listener. Have you tried that?

acepace commented 3 years ago

@jegesh your code forces the default session to be an IAM role rather than allowing it to use files.

seandickert commented 3 years ago

@jegesh would a better, and easier, solution to be just change the SqsListener object to take the boto3 session object as constructor parameter? Allows the user to decide how to initialize the AWS connection, which is probably how it should be. I can't think of a reason why the package should care how the connection is established.

To keep it backwards compatible, it could be passed in the kwargs object and default to current path if not available.

acepace commented 3 years ago

I forked the project, if there's interest