Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to delete aws iot things and policies?

Hello i want to delete things and policies created in AWS IoT.

While deleting thing i got this error =>

The action failed because the input is not valid. Cannot delete. Thing Arduino is still attached to one or more principals

While deleting certificate i got this error => The action failed because the resource conflicts with the precondition of the action. Certificate policies must be detached before deletion

While deleting policy i got this error => Failed to delete policy. The policy cannot be deleted as the policy is attached to one or more principals (name=policyyun)

can anyone help? Thanks.

like image 224
Abhijeet Kulkarni Avatar asked Mar 15 '16 05:03

Abhijeet Kulkarni


1 Answers

I am assuming the thing is created and it is attached to certificate along with the policy. Following is the order to follow while doing cleanup of thing. This will prevent DeleteConflictException due to associations.

  1. DetachPolicy - detach the policy from the certificate
  2. DetachThingPrincipal - detach the certificate from the Thing
  3. UpdateCertificate to set to INACTIVE (or set ForceDelete=true in #4)
  4. DeleteCertificate
  5. DeletePolicy
  6. DeleteThing

Note: You can get the array of principals(cert ARNs) associated with thing using ListThingPrincipals

p.s. The bold texts are APIs in most of the AWS IOT SDK bundles

like image 193
Jey Avatar answered Sep 21 '22 13:09

Jey