def handler()

in SubTemplates/IoT/Lambdas/cert_rotation_hook/app.py [0:0]


def handler(event, context):

    # Future log Cloudwatch logs
    print("Received event: " + json.dumps(event, indent=2))

    thing_name = event['parameters']['DeviceSerial']
    response = client.describe_thing(
    thingName=thing_name)
 
    try:
      #Cross reference ID of requester with entry in registery to ensure device needs a rotation.
      if int(response['attributes']['cert_issuance']) < int(target_date):
        deactivate_cert(thing_name)
        provision_response["allowProvisioning"] = True
    except:
      provision_response["allowProvisioning"] = False

    return provision_response