in provisioning_lambda/clients/iot.py [0:0]
def delete_thing(self, thing_name):
self.logger.info('Delete IoT Thing %s', thing_name)
try:
response = self.client.list_thing_principals(thingName=thing_name)
except self.client.exceptions.ResourceNotFoundException:
self.logger.warning('Thing %s does not exist.', thing_name)
else:
for principal in response['principals']:
self.client.detach_thing_principal(thingName=thing_name, principal=principal)
return self.client.delete_thing(thingName=thing_name)