Search in sources :

Example 1 with DeleteConflictException

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

the class DeleteUser method main.

public static void main(String[] args) {
    final String USAGE = "To run this example, supply a username\n" + "Ex: DeleteUser <username>\n";
    if (args.length != 1) {
        System.out.println(USAGE);
        System.exit(1);
    }
    String username = args[0];
    final AmazonIdentityManagement iam = AmazonIdentityManagementClientBuilder.defaultClient();
    DeleteUserRequest request = new DeleteUserRequest().withUserName(username);
    try {
        iam.deleteUser(request);
    } catch (DeleteConflictException e) {
        System.out.println("Unable to delete user. Verify user is not" + " associated with any resources");
        throw e;
    }
    System.out.println("Successfully deleted IAM user " + username);
}
Also used : DeleteUserRequest(com.amazonaws.services.identitymanagement.model.DeleteUserRequest) DeleteConflictException(com.amazonaws.services.identitymanagement.model.DeleteConflictException) AmazonIdentityManagement(com.amazonaws.services.identitymanagement.AmazonIdentityManagement)

Aggregations

AmazonIdentityManagement (com.amazonaws.services.identitymanagement.AmazonIdentityManagement)1 DeleteConflictException (com.amazonaws.services.identitymanagement.model.DeleteConflictException)1 DeleteUserRequest (com.amazonaws.services.identitymanagement.model.DeleteUserRequest)1