Allow SQS to use environment variables

This commit is contained in:
Sander van de Graaf
2018-01-09 13:03:51 +01:00
parent e22546672e
commit 17ea1e7a7b
2 changed files with 10 additions and 7 deletions
+6 -3
View File
@@ -51,9 +51,12 @@ class Sqs(Broker):
@staticmethod @staticmethod
def get_connection(list_key=Conf.PREFIX): def get_connection(list_key=Conf.PREFIX):
return Session(aws_access_key_id=Conf.SQS['aws_access_key_id'], config = Conf.SQS
aws_secret_access_key=Conf.SQS['aws_secret_access_key'], if 'aws_region' in config:
region_name=Conf.SQS['aws_region']) config['region_name'] = config['aws_region']
del(config['aws_region'])
return Session(**config)
def get_queue(self): def get_queue(self):
self.sqs = self.connection.resource('sqs') self.sqs = self.connection.resource('sqs')
+4 -4
View File
@@ -229,7 +229,7 @@ All connection keywords are supported. See the `iron-mq <https://github.com/iron
sqs sqs
~~~ ~~~
To use Amazon SQS as a broker you need to provide the AWS region and credentials:: To use Amazon SQS as a broker you need to provide the AWS region and credentials either via the config, or any other boto3 configuration method::
# example SQS broker connection # example SQS broker connection
@@ -241,9 +241,9 @@ To use Amazon SQS as a broker you need to provide the AWS region and credentials
'queue_limit': 100, 'queue_limit': 100,
'bulk': 5, 'bulk': 5,
'sqs': { 'sqs': {
'aws_region': 'us-east-1', 'aws_region': 'us-east-1', # optional
'aws_access_key_id': 'ac-Idr.....YwflZBaaxI', 'aws_access_key_id': 'ac-Idr.....YwflZBaaxI', # optional
'aws_secret_access_key': '500f7b....b0f302e9' 'aws_secret_access_key': '500f7b....b0f302e9' # optional
} }
} }