From ee7ec6b31abb05ae6bbaea51adaeafa6fe806cd2 Mon Sep 17 00:00:00 2001 From: Carl Oscar Aaro Date: Mon, 22 May 2017 22:24:32 +0200 Subject: [PATCH] Support for a 'generic' aws value in options that can hold region, secret key and access id to be shared among other AWS services --- tomodachi/transport/aws_sns_sqs.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tomodachi/transport/aws_sns_sqs.py b/tomodachi/transport/aws_sns_sqs.py index d07bacc3f..9703c88d9 100644 --- a/tomodachi/transport/aws_sns_sqs.py +++ b/tomodachi/transport/aws_sns_sqs.py @@ -170,9 +170,12 @@ def create_client(cls, name, context): loop = asyncio.get_event_loop() session = aiobotocore.get_session(loop=loop) - region_name = context.get('options', {}).get('aws_sns_sqs', {}).get('region_name') - aws_secret_access_key = context.get('options', {}).get('aws_sns_sqs', {}).get('aws_secret_access_key') - aws_access_key_id = context.get('options', {}).get('aws_sns_sqs', {}).get('aws_access_key_id') + config_base = context.get('options', {}).get('aws_sns_sqs', context.get('options', {}).get('aws', {})) + aws_config_base = context.get('options', {}).get('aws', {}) + + region_name = config_base.get('aws_region_name', config_base.get('region_name')) or aws_config_base.get('aws_region_name', config_base.get('region_name')) + aws_secret_access_key = config_base.get('aws_secret_access_key', config_base.get('secret_access_key')) or aws_config_base.get('aws_secret_access_key', config_base.get('secret_access_key')) + aws_access_key_id = config_base.get('aws_access_key_id', config_base.get('access_key_id')) or aws_config_base.get('aws_access_key_id', config_base.get('access_key_id')) try: cls.clients[name] = session.create_client(name, region_name=region_name, aws_secret_access_key=aws_secret_access_key, aws_access_key_id=aws_access_key_id)