def checkThingCertPolicySync()

in source/tools/test-dr-deployment.py [0:0]


def checkThingCertPolicySync(client, thingName):
    try:
        returnCheck=[]
        response = client.describe_thing(thingName=thingName)
        if response:
            returnCheck.append(response['thingName'])
            response = client.list_thing_principals(thingName=thingName)
            for principal in response['principals']:
                response = client.describe_certificate(certificateId=principal.split('/')[-1])
                returnCheck.append(response['certificateDescription']['certificateId'])

                response = client.list_principal_policies(principal=principal)

                for policy in response['policies']:
                    response = client.get_policy(policyName=policy['policyName'])
                    returnCheck.append(response['policyDocument'])
            logger.info(returnCheck)
            return returnCheck
        else:
            return returnCheck
    except client.exceptions.ResourceNotFoundException as e:
        logger.info('thing: {} not found'.format(thingName))
        return returnCheck
    except Exception as e:
        logger.error('ERROR: %s',e)