Search in sources :

Example 1 with GetAccessKeyLastUsedRequest

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");
}
Also used : GetAccessKeyLastUsedResponse(software.amazon.awssdk.services.iam.model.GetAccessKeyLastUsedResponse) GetAccessKeyLastUsedRequest(software.amazon.awssdk.services.iam.model.GetAccessKeyLastUsedRequest) IamException(software.amazon.awssdk.services.iam.model.IamException)

Aggregations

GetAccessKeyLastUsedRequest (software.amazon.awssdk.services.iam.model.GetAccessKeyLastUsedRequest)1 GetAccessKeyLastUsedResponse (software.amazon.awssdk.services.iam.model.GetAccessKeyLastUsedResponse)1 IamException (software.amazon.awssdk.services.iam.model.IamException)1