Detach principal from thing when it is deleted

This commit is contained in:
Emile Fugulin 2019-10-23 22:31:29 -04:00
commit 2d5e2e9c2b
2 changed files with 25 additions and 0 deletions

View file

@ -331,6 +331,12 @@ class IoTBackend(BaseBackend):
# can raise ResourceNotFoundError
thing = self.describe_thing(thing_name)
# detach all principals
for k in list(self.principal_things.keys()):
if k[1] == thing_name:
del self.principal_things[k]
del self.things[thing.arn]
def delete_thing_type(self, thing_type_name):