scripts/CheckDmsReplicationStatus.py [13:48]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    str_subject = event['Records'][0]['Sns']['Subject']
    if 'APPROVAL NEEDED' in str_subject:
        print('This is a Codepipeline approval action')
        str_sns = event['Records'][0]['Sns']['Message']
        sns_msg = json.loads(str_sns)
        pipeline = sns_msg['approval']['pipelineName']
        stage = sns_msg['approval']['stageName']
        action = sns_msg['approval']['actionName']
        token = sns_msg['approval']['token']
        approve_param ="pipelineName='%s',stageName='%s',actionName='%s',token='%s'" % ( pipeline , stage , action , token)
        print(approve_param)
        response = ssm.put_parameter(Name=ssm_parameter,
            Value=approve_param,
            Type='String',
            Overwrite=True
            )
    elif 'DMS' in str_subject:
        print('This is a message from DMS')
        str_sns = event['Records'][0]['Sns']['Message']
        if 'attempt' in str_sns:
            print(str_sns)
            print('Event notification nothing will be done')
        else:
            sns_msg = json.loads(str_sns)
            print(sns_msg['Event Message'])
            dms_status = sns_msg['Event Message']
            if 'STOPPED_AFTER_FULL_LOAD' in dms_status:
                print('DMS task replication is stopped after full load, proceeding to put an approval in Codepipeline')
                result_pipeline('Approved')
            elif 'started' in dms_status:
                print('Lambda will do nothing at this step as the task is started')
            elif 'Create' in dms_status:
                print('Lambda will do nothing at this step as the task is created')
            elif 'FAIL' in dms_status.upper():
                status = 'DMS task failed. Please check the task'
                print(status)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



templates/dms-automation-code-pipeline.template.yaml [649:684]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
            str_subject = event['Records'][0]['Sns']['Subject']
            if 'APPROVAL NEEDED' in str_subject:
              print('This is a Codepipeline approval action')
              str_sns = event['Records'][0]['Sns']['Message']
              sns_msg = json.loads(str_sns)
              pipeline = sns_msg['approval']['pipelineName']
              stage = sns_msg['approval']['stageName']
              action = sns_msg['approval']['actionName']
              token = sns_msg['approval']['token']
              approve_param ="pipelineName='%s',stageName='%s',actionName='%s',token='%s'" % ( pipeline , stage , action , token)
              print(approve_param)
              response = ssm.put_parameter(Name=ssm_parameter,
                  Value=approve_param,
                  Type='String',
                  Overwrite=True
                  )
            elif 'DMS' in str_subject:
              print('This is a message from DMS')
              str_sns = event['Records'][0]['Sns']['Message']
              if 'attempt' in str_sns:
                print(str_sns)
                print('Event notification nothing will be done')
              else:
                sns_msg = json.loads(str_sns)
                print(sns_msg['Event Message'])
                dms_status = sns_msg['Event Message']
                if 'STOPPED_AFTER_FULL_LOAD' in dms_status:
                  print('DMS task replication is stopped after full load, proceeding to put an approval in Codepipeline')
                  result_pipeline('Approved')
                elif 'started' in dms_status:
                  print('Lambda will do nothing at this step as the task is started')
                elif 'Create' in dms_status:
                  print('Lambda will do nothing at this step as the task is created')
                elif 'FAIL' in dms_status.upper():
                  status = 'DMS task failed. Please check the task'
                  print(status)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



