Search in sources :

Example 1 with DeleteAccessKeyRequest

use of software.amazon.awssdk.services.iam.model.DeleteAccessKeyRequest in project aws-doc-sdk-examples by awsdocs.

the class DeleteAccessKey method deleteKey.

// snippet-start:[iam.java2.delete_access_key.main]
public static void deleteKey(IamClient iam, String username, String accessKey) {
    try {
        DeleteAccessKeyRequest request = DeleteAccessKeyRequest.builder().accessKeyId(accessKey).userName(username).build();
        iam.deleteAccessKey(request);
        System.out.println("Successfully deleted access key " + accessKey + " from user " + username);
    } catch (IamException e) {
        System.err.println(e.awsErrorDetails().errorMessage());
        System.exit(1);
    }
}
Also used : DeleteAccessKeyRequest(software.amazon.awssdk.services.iam.model.DeleteAccessKeyRequest) IamException(software.amazon.awssdk.services.iam.model.IamException)

Aggregations

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