- AWS Code Sample demonstrates how to create a customer master key (CMK).

package aws.example.kms; import; import; import; import; public class CreateCustomerMasterKey { public static void main(String[] args) { AWSKMS kmsClient = AWSKMSClientBuilder.standard().build(); // Create a CMK String desc = "Key for protecting critical data"; CreateKeyRequest req = new CreateKeyRequest().withDescription(desc); CreateKeyResult result = kmsClient.createKey(req); System.out.printf( "Created a customer master key with id \"%s\"%n", result.getKeyMetadata().getArn() ); } }

Sample Details

Service: kms

Last tested: 2019-04-08

Author: AWS

Type: full-example