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);
}
}
Aggregations