Skip to content
This repository was archived by the owner on Oct 15, 2024. It is now read-only.

Commit 58e4627

Browse files
authored
Filter IAM roles and policy attachments related to SSO (#1028)
1 parent fb4e27a commit 58e4627

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

resources/iam-role-policy-attachments.go

+3
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ func (e *IAMRolePolicyAttachment) Filter() error {
8282
if strings.Contains(e.policyArn, ":iam::aws:policy/aws-service-role/") {
8383
return fmt.Errorf("cannot detach from service roles")
8484
}
85+
if strings.HasPrefix(*e.role.Path, "/aws-reserved/sso.amazonaws.com/") {
86+
return fmt.Errorf("cannot detach from SSO roles")
87+
}
8588
return nil
8689
}
8790

resources/iam-roles.go

+3
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ func (e *IAMRole) Filter() error {
7373
if strings.HasPrefix(e.path, "/aws-service-role/") {
7474
return fmt.Errorf("cannot delete service roles")
7575
}
76+
if strings.HasPrefix(e.path, "/aws-reserved/sso.amazonaws.com/") {
77+
return fmt.Errorf("cannot delete SSO roles")
78+
}
7679
return nil
7780
}
7881

0 commit comments

Comments
 (0)