aws_lambda_decorators/decorators.py
def extract_from_ssm(ssm_parameters):
    """
    Load given ssm parameters from AWS parameter store to the handler variables.

    Usage:
        @extract_from_ssm([SSMParameter(ssm_name="key", var_name="var")])
        def lambda_handler(var=None)
            pass

    Args:
        ssm_parameters (list): A collection of SSMParameter type items.
    """
    def decorator(func):
        def wrapper(*args, **kwargs):
            ssm = boto3.client("ssm")
            server_key_containers = ssm.get_parameters(
                Names=[ssm_parameter.get_ssm_name() for ssm_parameter in ssm_parameters],
                WithDecryption=True)
            for key_container in server_key_containers["Parameters"]:
                for ssm_parameter in ssm_parameters:  # pragma: no cover
                    if ssm_parameter.get_ssm_name() == key_container["Name"]:
                        kwargs[ssm_parameter.get_var_name()] = key_container["Value"]
                        break
            return func(*args, **kwargs)
        return wrapper
    return decorator

    Load given ssm parameters from AWS parameter store to the handler variables.

    Usage:
        @extract_from_ssm([SSMParameter(ssm_name="key", var_name="var")])
        def lambda_handler(var=None)
            pass

    Args:
        ssm_parameters (list): A collection of SSMParameter type items.
    
Load given ssm parameters from AWS parameter store to the handler variables.
Load given ssm parameters from AWS parameter store to the handler variables .
def extract_from_ssm(ssm_parameters):
    def decorator(func):
        def wrapper(*args, **kwargs):
            ssm = boto3.client("ssm")
            server_key_containers = ssm.get_parameters(
                Names=[ssm_parameter.get_ssm_name() for ssm_parameter in ssm_parameters],
                WithDecryption=True)
            for key_container in server_key_containers["Parameters"]:
                for ssm_parameter in ssm_parameters:  
                    if ssm_parameter.get_ssm_name() == key_container["Name"]:
                        kwargs[ssm_parameter.get_var_name()] = key_container["Value"]
                        break
            return func(*args, **kwargs)
        return wrapper
    return decorator
def extract_from_ssm ( ssm_parameters ) : def decorator ( func ) : def wrapper ( * args , ** kwargs ) : ssm = boto3 . client ( "ssm" ) server_key_containers = ssm . get_parameters ( Names = [ ssm_parameter . get_ssm_name ( ) for ssm_parameter in ssm_parameters ] , WithDecryption = True ) for key_container in server_key_containers [ "Parameters" ] : for ssm_parameter in ssm_parameters : if ssm_parameter . get_ssm_name ( ) == key_container [ "Name" ] : kwargs [ ssm_parameter . get_var_name ( ) ] = key_container [ "Value" ] break return func ( * args , ** kwargs ) return wrapper return decorator
Load given ssm parameters from AWS parameter store to the handler variables.
Load given ssm parameters from AWS parameter store to the handler variables .
"""
    Load given ssm parameters from AWS parameter store to the handler variables.

    Usage:
        @extract_from_ssm([SSMParameter(ssm_name="key", var_name="var")])
        def lambda_handler(var=None)
            pass

    Args:
        ssm_parameters (list): A collection of SSMParameter type items.
    """ # pragma: no cover
ssm_parameters
A collection of SSMParameter type items.
A collection of SSMParameter type items .