use of software.amazon.awssdk.services.iam.model.GetAccessKeyLastUsedRequest in project aws-doc-sdk-examples by awsdocs.
the class AccessKeyLastUsed method getAccessKeyLastUsed.
// snippet-start:[iam.java2.access_key_last_used.main]
public static void getAccessKeyLastUsed(IamClient iam, String accessId) {
try {
GetAccessKeyLastUsedRequest request = GetAccessKeyLastUsedRequest.builder().accessKeyId(accessId).build();
GetAccessKeyLastUsedResponse response = iam.getAccessKeyLastUsed(request);
System.out.println("Access key was last used at: " + response.accessKeyLastUsed().lastUsedDate());
} catch (IamException e) {
System.err.println(e.awsErrorDetails().errorMessage());
System.exit(1);
}
System.out.println("Done");
}
Aggregations