Search in sources :

Example 1 with DetachRolePolicyRequest

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);
    }
}
Also used : DetachRolePolicyRequest(software.amazon.awssdk.services.iam.model.DetachRolePolicyRequest) IamException(software.amazon.awssdk.services.iam.model.IamException)

Aggregations

DetachRolePolicyRequest (software.amazon.awssdk.services.iam.model.DetachRolePolicyRequest)1 IamException (software.amazon.awssdk.services.iam.model.IamException)1