Patchwork D6284: automation: detach policies before deleting role

login
register
mail settings
Submitter phabricator
Date May 15, 2019, 3:46 p.m.
Message ID <5d83038a1646693234afa0293389e99b@localhost.localdomain>
Download mbox | patch
Permalink /patch/40035/
State Not Applicable
Headers show

Comments

phabricator - May 15, 2019, 3:46 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGfcb97cb91ff8: automation: detach policies before deleting role (authored by indygreg, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6284?vs=14861&id=15088

REVISION DETAIL
  https://phab.mercurial-scm.org/D6284

AFFECTED FILES
  contrib/automation/hgautomation/aws.py

CHANGE DETAILS




To: indygreg, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/contrib/automation/hgautomation/aws.py b/contrib/automation/hgautomation/aws.py
--- a/contrib/automation/hgautomation/aws.py
+++ b/contrib/automation/hgautomation/aws.py
@@ -505,6 +505,10 @@ 
 
     for role in iamresource.roles.all():
         if role.name.startswith(prefix):
+            for p in role.attached_policies.all():
+                print('detaching policy %s from %s' % (p.arn, role.name))
+                role.detach_policy(PolicyArn=p.arn)
+
             print('removing role %s' % role.name)
             role.delete()