Creating an AWS KMS key - AWS SDK for Ruby

Creating an AWS KMS key

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

require "aws-sdk-kms" # v2: require 'aws-sdk' # Create a AWS KMS key. # As long we are only encrypting small amounts of data (4 KiB or less) directly, # a KMS key is fine for our purposes. # For larger amounts of data, # use the KMS key 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

See the complete example on GitHub.