def create()

in functions/source/CfnCrossRegion/lambda_function.py [0:0]


def create(event, context):
    """
    Create a cfn stack using an assumed role
    """
    print("**8**")
    cfn_capabilities = []
    if 'capabilities' in event['ResourceProperties'].keys():
        cfn_capabilities = event['ResourceProperties']['Capabilities']
    cfn_client = boto3.client("cloudformation")
    params = get_cfn_parameters(event)
    prefix = event['ResourceProperties']['ParentStackId'].split("/")[1]
    suffix = "-" + event["LogicalResourceId"] + "-" + rand_string(13)
    parent_properties = cfn_client.describe_stacks(StackName=prefix)['Stacks'][0]
    cfn_client = get_client("cloudformation", event, context)
    prefix_length = len(prefix)
    suffix_length = len(suffix)
    if prefix_length + suffix_length > 128:
        prefix = prefix[:128-suffix_length]
    stack_name = prefix + suffix
    capabilities = []
    if 'Capabilities' in parent_properties.keys():
        capabilities = parent_properties['Capabilities']
    print("**9**")
    print(event['ResourceProperties']['TemplateURL'])
    print(parent_properties)
    response = cfn_client.create_stack(
        StackName=stack_name,
        TemplateURL=event['ResourceProperties']['TemplateURL'],
        Parameters=params,
        Capabilities=capabilities,
        DisableRollback=parent_properties['DisableRollback'],
        NotificationARNs=parent_properties['NotificationARNs'],
        RollbackConfiguration=parent_properties['RollbackConfiguration'],
        Tags=[{
            'Key': 'ParentStackId',
            'Value': event['ResourceProperties']['ParentStackId']
        }] + parent_properties['Tags']
    )
    physical_resource_id = response['StackId']
    event["Poll"] = True
    event["PhysicalResourceId"] = physical_resource_id
    setup_poll(event, context)
    return physical_resource_id, {}