def lambda_handler()

in source/Create_SR.py [0:0]


def lambda_handler(event, context):
    try:
        # Parse the Lambda event JSON and get values needed for the creation of the SR
        ams_ct_id= event['change_type_id']
        ams_app_id= event['app_account_id']
        local_exec_params = event['exec_params']
        app_acct_role = event['app_acct_role']

    except Exception as missing_lambda_input:
        return(str(missing_lambda_input))


    if ams_ct_id == "Service_Request":
        #load the inputs for the SR from the local S3
        local_s3_session = boto3.session.Session()
        s3handler = local_s3_session.client('s3')
        bucket = S3bucket
        key  = templateS3Key + local_exec_params
        data = s3handler.get_object(Bucket=bucket, Key=key)
        # Load the SR exec params
        SRExecParams  = json.loads(data['Body'].read().decode('utf-8'))
        # Get a session in the destination account
        try:
            member_account_session = get_session(
                str(ams_app_id), str(app_acct_role), "create_sr",ExternalId
            )
        except (BotoCoreError, ClientError) as e:
            print("error getting session")
            logging.error(
            "get_session_with_arn() failed trying to assume role \
               due to clienterror or botocore error",
        )
        # Create an SR in the destination account
        try:
            supporthandler = member_account_session.client("support")
            print(supporthandler)
            response = supporthandler.create_case(
                subject=SRExecParams['subject'],
                serviceCode=SRExecParams['serviceCode'],
                severityCode=SRExecParams['severityCode'],
                categoryCode=SRExecParams['categoryCode'],
                communicationBody=SRExecParams['communicationBody'],
                ccEmailAddresses=[SRExecParams['ccEmailAddresses']]
            )
            NewCaseId = response['caseId']
            return {'caseId': NewCaseId}
        except Exception as create_sr_failure:
            return (str(create_sr_failure))

    else:
        return("Unknow_Request")