def check_properties()

in Lambda/BackupOrgPolicyManager/src/BackupOrgPolicyManager.py [0:0]


def check_properties(event):
    abort = False
    properties = {}
    msg = "SUCCESS"

    if 'ResourceProperties' in event:
        if 'PolicyName' in event['ResourceProperties']:
            properties['PolicyName'] = event['ResourceProperties']['PolicyName']
        else:
            msg = "No PolicyName specified in event['ResourceProperties']"
            logger.error(msg)
            abort = True

        if 'PolicyRegions' in event['ResourceProperties']:
            properties['PolicyRegions'] = event['ResourceProperties']['PolicyRegions']
        else:
            msg = "'PolicyRegions' has not been specified in 'ResourceProperties'"
            logger.error(msg)
            abort = True

        if 'OrgManagementAccount' in event['ResourceProperties']:
            properties['OrgManagementAccount'] = event['ResourceProperties']['OrgManagementAccount']
        else:
            msg = "'OrgManagementAccount' has not been specified.  This is required to manage backup policies in the org"
            logger.error(msg)

        if 'PolicyType' in event['ResourceProperties']:
            properties['PolicyType'] = event['ResourceProperties']['PolicyType']
        else:
            msg = "'PolicyType' has not been specified.  This is required to manage backup policies in the org"
            logger.error(msg)
            abort = True

        if 'PolicyDescription' in event['ResourceProperties']:
            properties['PolicyDescription'] = event['ResourceProperties']['PolicyDescription']
        else:
            msg = "'PolicyDescription' has not been specified.  This is required to manage backup policies in the org"
            logger.error(msg)
            abort = True

        if 'PolicyTargets' in event['ResourceProperties']:
            properties['PolicyTargets'] = event['ResourceProperties']['PolicyTargets']
        else:
            msg = "No policy targets specified in 'ResourceProperties'"
            logger.error(msg)
            abort = True

        if 'PolicyContent' in event['ResourceProperties']:
            properties['PolicyContent'] = event['ResourceProperties']['PolicyContent']
        else:
            msg = "'PolicyContent' has not been specified.  This is required to manage backup policies in the org"
            logger.error(msg)
            abort = True

        if 'Variables' in event['ResourceProperties']:
            properties['Variables'] = event['ResourceProperties']['Variables']
        else:
            properties['Variables'] = []
            logger.info(
                "'Variables' has not been specified.")

    else:
        logger.error("No 'ResourceProperties' in event")
        abort = True

    if abort:
        return {
            'success': False,
            'message': msg
        }
    else:
        return {
            'success': True,
            'properties': properties
        }