AWS SDK for Ruby
Developer Guide

Creating a CMK in AWS KMS

The following example uses the AWS SDK for Rubycreate_key method, which implements the CreateKey operation to create a customer master key (CMK). Because the example only encrypts a small amount of data, a CMK is fine for our purposes. For larger amounts of data, use the CMK to encrypt a data encryption key (DEK).

require 'aws-sdk-kms' # v2: require 'aws-sdk' # Create a customer master key (CMK). # As long we are only encrypting small amounts of data (4 KiB or less) directly, # a CMK is fine for our purposes. # For larger amounts of data, # use the CMK to encrypt a data encryption key (DEK). client = Aws::KMS::Client.new resp = client.create_key({ tags: [ { tag_key: 'CreatedBy', tag_value: 'ExampleUser' }, ], }) puts resp.key_metadata.key_id

Choose Copy to save the code locally. See the complete example on GitHub.