-
Notifications
You must be signed in to change notification settings - Fork 5.8k
/
Copy pathcreate_key.rb
32 lines (24 loc) · 989 Bytes
/
create_key.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
# frozen_string_literal: true
# Purpose:
# create_key.rb demonstrates how to create a AWS KMS key
# using Amazon Key Management Services (AWS KMS) using the AWS SDK for Ruby.
# snippet-start:[kms.ruby.createKey]
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
# snippet-end:[kms.ruby.createKey]