PK!ĵpyramid_ssm_settings.pyimport os import boto3 def includeme(config): config.add_settings(load_settings(config)) config.add_settings(interpolate_envvars(config)) def load_settings(config): """ Load settings from AWS Parameter Store. """ path = _get_path(config) if not path: return client = boto3.client('ssm') next_token = None settings = dict() while True: kwargs = { 'Path': path, 'WithDecryption': True, } if next_token: kwargs['NextToken'] = next_token response = client.get_parameters_by_path(**kwargs) for param in response['Parameters']: key = param['Name'][len(path):] settings[key] = param['Value'] if 'NextToken' in response: next_token = response['NextToken'] else: break return settings def _get_path(config): settings = config.get_settings() if 'ssm.path' in settings: return settings['ssm.path'] elif 'SSM_PATH' in os.environ: return os.environ['SSM_PATH'] else: return None def interpolate_envvars(config): """ Insert environment variables into settings using format minilang. """ settings = config.get_settings() new_settings = dict() for key, val in settings.items(): if isinstance(val, str) and '{' in val: new_settings[key] = val.format(**os.environ) return new_settings PK!H IJ,,,pyramid_ssm_settings-0.2.0.dist-info/LICENSEMIT License Copyright (c) 2018 Theron Luhn 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!HnHTU*pyramid_ssm_settings-0.2.0.dist-info/WHEEL A н#Z;/"d&F[xzw@Zpy3Fv]\fi4WZ^EgM_-]#0(q7PK!HDuU-pyramid_ssm_settings-0.2.0.dist-info/METADATARn0+%Lɯ(a1 ंN(J|}Wy#wgvgs16jk2%+W&7PlkulM] # ;C#f⋷(.ygEP쳃yT.?emnovbP壂]Zhs纛 ٘I-|M)Z:%so'k,:bŚJ$,PwWI!D"(E%l ڕ ÿz^M{3.{3>f|wI`Oj>> f s@f`'!it&'U.#:kG7G qv:,PK!H2+pyramid_ssm_settings-0.2.0.dist-info/RECORDͶB@}ς1,Z G#JOfx{7 |ci] cu}_6#Ǯ)1h3#OFjVt)MjYbxrE~٦hl؅DbM|f$m\==RTVx{ơB;2RhoP3fJ0AD(HoO\I^6@=Mq(i^a6PK!ĵpyramid_ssm_settings.pyPK!H IJ,,,pyramid_ssm_settings-0.2.0.dist-info/LICENSEPK!HnHTU*` pyramid_ssm_settings-0.2.0.dist-info/WHEELPK!HDuU- pyramid_ssm_settings-0.2.0.dist-info/METADATAPK!H2+ pyramid_ssm_settings-0.2.0.dist-info/RECORDPK