def on_message_callback()

in SubTemplates/IoT/Lambdas/provision_device/client/provisioning_handler.py [0:0]


    def on_message_callback(self, message):
        """ Callback Message handler responsible for workflow routing of msg responses from provisioning services.
        
        Arguments:
            message {string} -- The response message payload.
        """
        json_data = json.loads(message.payload)
        
        # A response has been recieved from the service that contains certificate data. 
        if 'certificateId' in json_data:
            self.logger.info('##### SUCCESS. SAVING KEYS TO DEVICE! #####')
            print('##### SUCCESS. SAVING KEYS TO DEVICE! #####')
            self.assemble_certificates(json_data)
        
        # A response contains acknowledgement that the provisioning template has been acted upon.
        elif 'deviceConfiguration' in json_data:
            if self.isRotation:
                self.logger.info('##### ACTIVATION COMPLETE #####')
                print('##### ACTIVATION COMPLETE #####')
            else:
                self.logger.info('##### CERT ACTIVATED AND THING {} CREATED #####'.format(json_data['thingName']))
                print('##### CERT ACTIVATED AND THING {} CREATED #####'.format(json_data['thingName']))

            self.validate_certs() 
        elif 'statusCode' in json_data:
            if json_data['statusCode'] == 403:
                os.remove("{}/{}".format(self.secure_cert_path,self.new_key_name))
                os.remove("{}/{}".format(self.secure_cert_path,self.new_cert_name))
        else:
            self.logger.info(json_data)