use of com.amazonaws.services.ec2.model.CreateKeyPairRequest in project incubator-gobblin by apache.
the class AWSSdkClient method createKeyValuePair.
/**
* Creates a 2048-bit RSA key pair with the specified name
*
* @param keyName Key name to use
* @return Unencrypted PEM encoded PKCS#8 private key
*/
public String createKeyValuePair(String keyName) {
final AmazonEC2 amazonEC2 = getEc2Client();
final CreateKeyPairRequest createKeyPairRequest = new CreateKeyPairRequest().withKeyName(keyName);
final CreateKeyPairResult createKeyPairResult = amazonEC2.createKeyPair(createKeyPairRequest);
final KeyPair keyPair = createKeyPairResult.getKeyPair();
final String material = keyPair.getKeyMaterial();
LOGGER.info("Created key: " + keyName);
LOGGER.debug("Created material: " + material);
return material;
}
Aggregations