def handler()

in functions/source/update_custommanagedvpc_iam_role.py [0:0]


def handler(event, context):
    # make sure we send a failure to CloudFormation if the function
    # is going to timeout
    timer = threading.Timer((context.get_remaining_time_in_millis()
            / 1000.00) - 0.5, timeout, args=[event, context])
    timer.start()
    print('Received event: %s' % json.dumps(event))
    status = cfnresponse.SUCCESS
    
    try:
        role_name = event['ResourceProperties']['role_name']
        aws_region = event['ResourceProperties']['aws_region']
        accountId = event['ResourceProperties']['accountId']
        security_group_ids = event['ResourceProperties']['security_group_ids']
        vpcid = event['ResourceProperties']['VPCID']
        
        print('role_name - '+role_name)
        print('aws_region - '+aws_region)
        print('account_Id - '+accountId)
        print('security_group_ids - '+security_group_ids)
        print('vpcid - '+vpcid)
        
        if event['RequestType'] == 'Create':
            put_role_policy_sg(role_name, aws_region, accountId, security_group_ids, vpcid)
        else:
            pass
    except Exception as e:
        logging.error('Exception: %s' % e, exc_info=True)
        status = cfnresponse.FAILED
    finally:
        timer.cancel()
        cfnresponse.send(event, context, status, {}, None)