use of software.amazon.awssdk.services.iam.model.DetachRolePolicyRequest in project aws-doc-sdk-examples by awsdocs.
the class DetachRolePolicy method detachPolicy.
// snippet-start:[iam.java2.detach_role_policy.main]
public static void detachPolicy(IamClient iam, String roleName, String policyArn) {
try {
DetachRolePolicyRequest request = DetachRolePolicyRequest.builder().roleName(roleName).policyArn(policyArn).build();
iam.detachRolePolicy(request);
System.out.println("Successfully detached policy " + policyArn + " from role " + roleName);
} catch (IamException e) {
System.err.println(e.awsErrorDetails().errorMessage());
System.exit(1);
}
}
Aggregations