PK!+[ DDdecouple_aws/__init__.pyimport logging from decouple import AutoConfig, Config from .exceptions import AWSException from .repository import RepositoryAwsSecretManager # We do this assertion so pyflakes doesn't complain assert RepositoryAwsSecretManager logger = logging.getLogger(__name__) def get_config(source, region): """ Get config object but fallback to AutoConfig if AWS connection fails""" try: logger.debug( 'Querying AWS Secrets manager for %s in region %s', source, region) repo = RepositoryAwsSecretManager(source, region) logger.debug('Successfully queried for %s in region %s', source, region) return Config(repo) except AWSException as e: logger.error( 'Failed retrieving secrets from AWS Secrets Manager: %s', e) return AutoConfig() PK!++decouple_aws/exceptions.pyclass AWSException(RuntimeError): pass PK!}11decouple_aws/repository.pyimport json import os import boto3 from .exceptions import AWSException class RepositoryAwsSecretManager: """ Retrieves option keys from AWS Secret Manager or falls back to os.environ """ data = {} def __init__(self, source, region): self.client = boto3.client('secretsmanager', region_name=region) try: response = self.client.get_secret_value(SecretId=source) parsed_secrets = json.loads(response['SecretString']) for k, v in parsed_secrets.items(): self.data[k] = v except self.client.exceptions.ClientError as e: raise AWSException(str(e)) from e def __contains__(self, key): return key in os.environ or key in self.data def __getitem__(self, key): return self.data[key] PK!J]--+python_decouple_aws-0.3.0.dist-info/LICENSE MIT License Copyright (c) 2018, Matt Magin Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. PK!H\TT)python_decouple_aws-0.3.0.dist-info/WHEEL 1 0 нR \I$ơ7.ZON `h6oi14m,b4>4ɛpK>X;baP>PK!H\ળ ,python_decouple_aws-0.3.0.dist-info/METADATAU]oF}_q}H|+y7$jQO\tmtf a}&FB=s5UA%T)SqJNɮTɔ3SۂD1RUJocy\SO3hظu.~3%'V<uO23eΘޮ:CXx &_ _G J)8e<%+1T?v쓶^ˋ/pU(L3v(M:iGЙܩUNk |;^^?ikCJO&s:zy*?9'Go-mi#smJ#`x?y\ϜKL dK{NBcԫ%(ҍJuK?\LԱ{]HJr9M#[i\׺*``8E;vB;|9 !&UMIe{O>Nf &]a81%Gs8xSN 1 o0MٓʯnsB|to99wrx2`g TOhy3]1My"B5fjQ(Ie?J$.!CG^Vt;N>gʦs]I%囬%:LtUM9AlmCJH55V;w>%?X nyf蓇G uG̭qT3}'Ң1Wz (Z:e-`*kz|(:H\-UꩈA4adC֚xS7"lO8ѧ1|RbØc_u7fdpVvYD PK!HdI*python_decouple_aws-0.3.0.dist-info/RECORDv0н߂b\tF#&*IBx-R|i- Qι67CKceo JN/ `M'cPnNg5ݓi{!vN6מUyEYWK&'P l=q-dg!ȅ4  Q Oՙ>SgeiMmhG~!}< `v AVȽ!\td.B =]޵P}c!F\||fm|b˱bQlR~pU,N>䧃0BЬ`(75$D:2PK!+[ DDdecouple_aws/__init__.pyPK!++zdecouple_aws/exceptions.pyPK!}11decouple_aws/repository.pyPK!J]--+Fpython_decouple_aws-0.3.0.dist-info/LICENSEPK!H\TT) python_decouple_aws-0.3.0.dist-info/WHEELPK!H\ળ ,W python_decouple_aws-0.3.0.dist-info/METADATAPK!HdI*python_decouple_aws-0.3.0.dist-info/RECORDPK8e