AWS code-library documentation change
Summary
Added PowerShell V5 examples for DeleteRole operation including policy detachment guidance
Security assessment
Demonstrates proper role deletion process including policy detachment, which helps prevent accidental privilege retention but doesn't address a specific vulnerability
Diff
diff --git a/code-library/latest/ug/iam_example_iam_DeleteRole_section.md b/code-library/latest/ug/iam_example_iam_DeleteRole_section.md index 1f5bf5325..092fe23d6 100644 --- a//code-library/latest/ug/iam_example_iam_DeleteRole_section.md +++ b//code-library/latest/ug/iam_example_iam_DeleteRole_section.md @@ -290,0 +291,21 @@ PowerShell +**Tools for PowerShell V5** + + +**Example 1: This example deletes the role named`MyNewRole` from the current IAM account. Before you can delete the role you must first use the `Unregister-IAMRolePolicy` command to detach any managed policies. Inline policies are deleted with the role.** + + + Remove-IAMRole -RoleName MyNewRole + + +**Example 2: This example detaches any managed policies from the role named`MyNewRole` and then deletes the role. The first line retrieves any managed policies attached to the role as a collection and then detaches each policy in the collection from the role. The second line deletes the role itself. Inline policies are deleted along with the role.** + + + Get-IAMAttachedRolePolicyList -RoleName MyNewRole | Unregister-IAMRolePolicy -RoleName MyNewRole + Remove-IAMRole -RoleName MyNewRole + + + * For API details, see [DeleteRole](https://docs.aws.amazon.com/powershell/v5/reference) in _AWS Tools for PowerShell Cmdlet Reference (V5)_. + + + +