Search in sources :

Example 1 with DetachRolePolicyRequest

use of com.amazonaws.services.identitymanagement.model.DetachRolePolicyRequest in project aws-doc-sdk-examples by awsdocs.

the class DetachRolePolicy method main.

public static void main(String[] args) {
    final String USAGE = "To run this example, supply a role name and policy arn\n" + "Ex: DetachRolePolicy <role-name> <policy-arn>>\n";
    if (args.length != 1) {
        System.out.println(USAGE);
        System.exit(1);
    }
    String role_name = args[0];
    String policy_arn = args[1];
    final AmazonIdentityManagement iam = AmazonIdentityManagementClientBuilder.defaultClient();
    DetachRolePolicyRequest request = new DetachRolePolicyRequest().withRoleName(role_name).withPolicyArn(policy_arn);
    DetachRolePolicyResult response = iam.detachRolePolicy(request);
    System.out.println("Successfully detached policy " + policy_arn + " from role " + role_name);
}
Also used : DetachRolePolicyRequest(com.amazonaws.services.identitymanagement.model.DetachRolePolicyRequest) DetachRolePolicyResult(com.amazonaws.services.identitymanagement.model.DetachRolePolicyResult) AmazonIdentityManagement(com.amazonaws.services.identitymanagement.AmazonIdentityManagement)

Aggregations

AmazonIdentityManagement (com.amazonaws.services.identitymanagement.AmazonIdentityManagement)1 DetachRolePolicyRequest (com.amazonaws.services.identitymanagement.model.DetachRolePolicyRequest)1 DetachRolePolicyResult (com.amazonaws.services.identitymanagement.model.DetachRolePolicyResult)1