def secrets_manager(*secret_names):
    """
    Get secrets from the `AWS Secrets Manager <https://aws.amazon.com/secrets-manager/>`_.

    Secrets are added to a dictionary named ``secrets`` on the context object.

    This requires your lambda to have the ``secretsmanager:GetSecretValue`` permission for the
    requested secret and ``kms:Decrypt`` for any keys used to encrypt the secrets.

    Usage::

      >>> from lambda_decorators import secrets_manager
      >>> @secrets_manager('dschep/test')
      ... def secret_getter(event, context):
      ...     return context.secrets
      >>> class Context:
      ...     pass
      >>> secret_getter({}, Context())
      {'dschep/test': {'foo': 'b4r', 'floo': 'b4z'}}

    """
    def wrapper_wrapper(handler):
        @wraps(handler)
        def wrapper(event, context):
            if not hasattr(context, 'secrets'):
                context.secrets = {}
            for secret_name in secret_names:
                secret_value = boto3.client(service_name='secretsmanager').get_secret_value(SecretId=secret_name)
                if 'SecretString' in secret_value:
                    context.secrets[secret_name] = json.loads(secret_value['SecretString'])
                else:
                    context.secrets[secret_name] = secret_value['SecretBinary']

            return handler(event, context)

        return wrapper

    return wrapper_wrapper