def replace_lambda_context_resource_handler(event, context):
    """Lambda handler function to replace the execution context for a Lambda function, as a CloudFormation resource.

    This is intended to be used in an inline deployment. The physical ID is
    the Revision ID of the Lambda Function
    """
    import cfnresponse
    import logging
    from datetime import datetime
    logging.basicConfig(level=logging.DEBUG)
    LOGGER = logging.getLogger('replacer')
    try:
        import boto3
        lambdaclient = boto3.client('lambda')
        response = {}
        physical_id = event.get('PhysicalResourceId')
        if event['RequestType'] in ['Create', 'Update']:
            properties = event['ResourceProperties']
            old_config = lambdaclient.get_function_configuration(FunctionName
                =properties['FunctionName'])
            new_environment = old_config['Environment']['Variables']
            new_environment['SSMASH_UPDATED_TIMESTAMP'] = datetime.isoformat(
                datetime.utcnow())
            response = lambdaclient.update_function_configuration(FunctionName
                =properties['FunctionName'], Environment={'Variables':
                new_environment}, RevisionId=old_config['RevisionId'])
            physical_id = response['RevisionId']
        elif event['RequestType'] == 'Delete':
            LOGGER.info(
                'Ignoring request to delete resource for Lambda replacement context %s'
                , physical_id)
        else:
            raise ValueError('Unknown CloudFormation request type')
        cfnresponse.send(event, context, cfnresponse.SUCCESS, response,
            physical_id)
    except Exception as ex:
        LOGGER.exception('argh!')
        cfnresponse.send(event, context, cfnresponse.FAILED, {})
