use of software.amazon.awssdk.services.iam.model.CreateAccessKeyResponse in project aws-doc-sdk-examples by awsdocs.
the class CreateAccessKey method createIAMAccessKey.
// snippet-start:[iam.java2.create_access_key.main]
public static String createIAMAccessKey(IamClient iam, String user) {
try {
CreateAccessKeyRequest request = CreateAccessKeyRequest.builder().userName(user).build();
CreateAccessKeyResponse response = iam.createAccessKey(request);
String keyId = response.accessKey().accessKeyId();
return keyId;
} catch (IamException e) {
System.err.println(e.awsErrorDetails().errorMessage());
System.exit(1);
}
return "";
}
Aggregations