PK!W ssmenv/__init__.pyimport functools import os import re from collections import UserDict import boto3 class SSMEnv(UserDict): def __init__(self, *args, prefixes=None, ssm_client=None, no_aws_default=None): self._include = args self._prefixes = prefixes self._ssm_client = ssm_client self._no_aws_default = no_aws_default super().__init__(self._load()) def _load(self): if self._no_aws_default and not any( ( os.environ.get("AWS_ACCESS_KEY_ID"), os.environ.get("AWS_CONTAINER_CREDENTIALS_RELATIVE_URI"), ) ): return self._no_aws_default ssm = self._ssm_client or boto3.client("ssm") parameters = {} for namespace in self._include: params = [] next_token = -1 while next_token != 0: search_params = { "Path": namespace, "WithDecryption": True, "Recursive": True, } if next_token != -1: search_params["NextToken"] = next_token current_set = ssm.get_parameters_by_path(**search_params) params += current_set.get("Parameters") next_token = current_set.get("NextToken", 0) for param in params: name = self._normalize_name(self._remove_prefixes(param.get("Name"))) parameters[name] = param.get("Value") return parameters def _remove_prefixes(self, name): if not self._prefixes: return name for prefix in self._prefixes: if name.startswith(prefix): name = name.replace(prefix, "") return name def _normalize_name(self, name): return re.sub(r"\W", "_", name).upper().strip("_") _lambda_ssmenv = None def ssmenv(*args, **kwargs): def wrapper_wrapper(handler): @functools.wraps(handler) def wrapper(event, context): if not hasattr(context, "params"): context.params = {} global _lambda_ssmenv if not _lambda_ssmenv: _lambda_ssmenv = SSMEnv(*args, **kwargs) context.params = ( _lambda_ssmenv if _lambda_ssmenv else SSMEnv(*args, **kwargs) ) return handler(event, context) return wrapper return wrapper_wrapper PK!e1..ssmenv-2.0.0.dist-info/LICENSEMIT License Copyright (c) 2018 Daniel Ancuta 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!Hu)GTUssmenv-2.0.0.dist-info/WHEEL HM K-*ϳR03rOK-J,/R(O-)$qzd&Y)r$UV&UrPK!H֨`_ssmenv-2.0.0.dist-info/METADATAWms6_Q>kW_^=uM1!r% ,JQF3ɇ"o>|^‹gN=/{QQ///i[®'pY9XFXdskj8.w0"]i `4ٹVyRb,Ԙ6bAT7n2/YVzS B}w1 +cK7rfDFRǩgHZ_;7BKTpoST}ߜArO/״UۿHpN%[\2 e [ RlCcZ)ܳ{Ý{ϵG]b gm)Q&]djtzgMc͒L'~yCh :R{  k6zR$"CrZj}d,>F05sDOVےt~LWpѷ4hÄ bW'c ʆ6L ~\74?1miV:IwĨ$MjxL r'}A#2{gj*;zҧXJ23vq}斋NNcJGZ!|g6ˤ[x&&RFqv͡qLݺ"sN5F;HDPv'~]?Y/]ߏ0TH>rlpIt&jс.Kkvp~:Vx! !g'L9IT fV:K&4zv9h2s(0KxlP$R(xsfƤ U5QCcA@#idp$0h|͊-QH3-zCjc9,IP|$bͰX́< bH|[$CMrEj 1[m̷aK+IwIT(tv_QgD^fp_ "90'`oor?~_͗=r A#=@0P_Z MdFA ME ]njb:#e RZ ǯ64K~06*UDt7O$C5aapcZÀ_0%'>nnZ찞ȺB -+T8mDoo:/qw hi0|l[?ǮĿPK!HȿZmssmenv-2.0.0.dist-info/RECORDur0л4")d 4İ_Ng82(aywa~Nf EqOb: *$ ސקSS3#`9[aiultMƆ6!;l~Xss+pe2f.*R4='[(¥W1 FskE\D95^p]UdwR K;HAWֵ#-prMb(!W*+y'kaٴVPK!W ssmenv/__init__.pyPK!e1.. ssmenv-2.0.0.dist-info/LICENSEPK!Hu)GTU0ssmenv-2.0.0.dist-info/WHEELPK!H֨`_ssmenv-2.0.0.dist-info/METADATAPK!HȿZmssmenv-2.0.0.dist-info/RECORDPKn3