Skip to content

Commit ee430ca

Browse files
Merge customizations for KMS
1 parent 8c6de22 commit ee430ca

16 files changed

Lines changed: 152 additions & 25 deletions

awscli/examples/kms/create-key.rst

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Output::
1717
"AWSAccountId": "111122223333",
1818
"Arn": "arn:aws:kms:us-west-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab",
1919
"CreationDate": "2017-07-05T14:04:55-07:00",
20+
"CurrentKeyMaterialId": "0b7fd7ddbac6eef27907413567cad8c810e2883dc8a7534067a82ee1142fc1e6",
2021
"CustomerMasterKeySpec": "SYMMETRIC_DEFAULT",
2122
"Description": "",
2223
"Enabled": true,
@@ -40,7 +41,7 @@ For more information, see `Creating keys <https://docs.aws.amazon.com/kms/latest
4041

4142
**Example 2: To create an asymmetric RSA KMS key for encryption and decryption**
4243

43-
The following ``create-key`` example creates a KMS key that contains an asymmetric RSA key pair for encryption and decryption. ::
44+
The following ``create-key`` example creates a KMS key that contains an asymmetric RSA key pair for encryption and decryption. The key spec and key usage can't be changed after the key is created.::
4445

4546
aws kms create-key \
4647
--key-spec RSA_4096 \
@@ -75,7 +76,7 @@ For more information, see `Asymmetric keys in AWS KMS <https://docs.aws.amazon.c
7576

7677
**Example 3: To create an asymmetric elliptic curve KMS key for signing and verification**
7778

78-
To create an asymmetric KMS key that contains an asymmetric elliptic curve (ECC) key pair for signing and verification. The ``--key-usage`` parameter is required even though ``SIGN_VERIFY`` is the only valid value for ECC KMS keys. ::
79+
To create an asymmetric KMS key that contains an asymmetric elliptic curve (ECC) key pair for signing and verification. The ``--key-usage`` parameter is required even though ``SIGN_VERIFY`` is the only valid value for ECC KMS keys. The key spec and key usage can't be changed after the key is created.::
7980

8081
aws kms create-key \
8182
--key-spec ECC_NIST_P521 \
@@ -105,10 +106,43 @@ Output::
105106
}
106107

107108

108-
For more information, see `Asymmetric keys in AWS KMS <https://docs.aws.amazon.com/kms/latest/developerguide/symmetric-asymmetric.html>`__ in the *AWS Key Management Service Developer Guide*.
109+
For more information, see `Asymmetric keys in AWS KMS <https://docs.aws.amazon.com/kms/latest/developerguide/symmetric-asymmetric.html>`__ in the *AWS Key Management Service Developer Guide*.
110+
111+
**Example 4: To create an asymmetric ML-DSA KMS key for signing and verification**
112+
113+
This example creates a module-lattice digital signature algorithm (ML-DSA) key for signing and verification. The key-usage parameter is required even though ``SIGN_VERIFY`` is the only valid value for ML-DSA keys. ::
114+
115+
aws kms create-key \
116+
--key-spec ML_DSA_65 \
117+
--key-usage SIGN_VERIFY
118+
119+
Output::
120+
121+
{
122+
"KeyMetadata": {
123+
"Arn": "arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab",
124+
"AWSAccountId": "111122223333",
125+
"CreationDate": "2019-12-02T07:48:55-07:00",
126+
"Description": "",
127+
"Enabled": true,
128+
"KeyId": "1234abcd-12ab-34cd-56ef-1234567890ab",
129+
"KeyManager": "CUSTOMER",
130+
"KeySpec": "ML_DSA_65",
131+
"KeyState": "Enabled",
132+
"KeyUsage": "SIGN_VERIFY",
133+
"MultiRegion": false,
134+
"Origin": "AWS_KMS",
135+
"SigningAlgorithms": [
136+
"ML_DSA_SHAKE_256"
137+
]
138+
}
139+
}
140+
141+
142+
For more information, see `Asymmetric keys in AWS KMS <https://docs.aws.amazon.com/kms/latest/developerguide/symmetric-asymmetric.html>`__ in the *AWS Key Management Service Developer Guide*.
109143

110144

111-
**Example 4: To create an HMAC KMS key**
145+
**Example 5: To create an HMAC KMS key**
112146

113147
The following ``create-key`` example creates a 384-bit HMAC KMS key. The ``GENERATE_VERIFY_MAC`` value for the ``--key-usage`` parameter is required even though it's the only valid value for HMAC KMS keys. ::
114148

@@ -142,7 +176,7 @@ Output::
142176
For more information, see `HMAC keys in AWS KMS <https://docs.aws.amazon.com/kms/latest/developerguide/hmac.html>`__ in the *AWS Key Management Service Developer Guide*.
143177

144178

145-
**Example 4: To create a multi-Region primary KMS key**
179+
**Example 6: To create a multi-Region primary KMS key**
146180

147181
The following ``create-key`` example creates a multi-Region primary symmetric encryption key. Because the default values for all parameters create a symmetric encryption key, only the ``--multi-region`` parameter is required for this KMS key. In the AWS CLI, to indicate that a Boolean parameter is true, just specify the parameter name. ::
148182

@@ -156,6 +190,7 @@ Output::
156190
"Arn": "arn:aws:kms:us-west-2:111122223333:key/mrk-1234abcd12ab34cd56ef12345678990ab",
157191
"AWSAccountId": "111122223333",
158192
"CreationDate": "2021-09-02T016:15:21-09:00",
193+
"CurrentKeyMaterialId": "0b7fd7ddbac6eef27907413567cad8c810e2883dc8a7534067a82ee1142fc1e6",
159194
"CustomerMasterKeySpec": "SYMMETRIC_DEFAULT",
160195
"Description": "",
161196
"Enabled": true,
@@ -183,7 +218,7 @@ Output::
183218
For more information, see `Asymmetric keys in AWS KMS <https://docs.aws.amazon.com/kms/latest/developerguide/symmetric-asymmetric.html>`__ in the *AWS Key Management Service Developer Guide*.
184219

185220

186-
**Example 5: To create a KMS key for imported key material**
221+
**Example 7: To create a KMS key for imported key material**
187222

188223
The following ``create-key`` example creates a creates a KMS key with no key material. When the operation is complete, you can import your own key material into the KMS key. To create this KMS key, set the ``--origin`` parameter to ``EXTERNAL``. ::
189224

@@ -253,7 +288,7 @@ Output::
253288
For more information, see `AWS CloudHSM key stores <https://docs.aws.amazon.com/kms/latest/developerguide/keystore-cloudhsm.html>`__ in the *AWS Key Management Service Developer Guide*.
254289

255290

256-
**Example 7: To create a KMS key in an external key store**
291+
**Example 8: To create a KMS key in an external key store**
257292

258293
The following ``create-key`` example creates a creates a KMS key in the specified external key store. The ``--custom-key-store-id``, ``--origin``, and ``--xks-key-id`` parameters are required in this command.
259294

awscli/examples/kms/delete-imported-key-material.rst

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ The following ``delete-imported-key-material`` example deletes key material that
55
aws kms delete-imported-key-material \
66
--key-id 1234abcd-12ab-34cd-56ef-1234567890ab
77

8-
This command produces no output. To verify that the key material is deleted, use the ``describe-key`` command to look for a key state of ``PendingImport`` or ``PendingDeletion``.
98

10-
For more information, see `Deleting imported key material<https://docs.aws.amazon.com/kms/latest/developerguide/importing-keys-delete-key-material.html>`__ in the *AWS Key Management Service Developer Guide*.
9+
Output::
10+
11+
{
12+
"KeyId": "1234abcd-12ab-34cd-56ef-1234567890ab",
13+
"KeyMaterialId": "0b7fd7ddbac6eef27907413567cad8c810e2883dc8a7534067a82ee1142fc1e6"
14+
}
15+
16+
For more information, see `Deleting imported key material <https://docs.aws.amazon.com/kms/latest/developerguide/importing-keys-delete-key-material.html>`__ in the *AWS Key Management Service Developer Guide*.

awscli/examples/kms/describe-key.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Output::
1414
"AWSAccountId": "846764612917",
1515
"KeyId": "b8a9477d-836c-491f-857e-07937918959b",
1616
"Arn": "arn:aws:kms:us-west-2:846764612917:key/b8a9477d-836c-491f-857e-07937918959b",
17+
"CurrentKeyMaterialId": "0b7fd7ddbac6eef27907413567cad8c810e2883dc8a7534067a82ee1142fc1e6",
1718
"CreationDate": 2017-06-30T21:44:32.140000+00:00,
1819
"Enabled": true,
1920
"Description": "Default KMS key that protects my S3 objects when no other key is defined",
@@ -80,6 +81,7 @@ Output::
8081
"AWSAccountId": "111122223333",
8182
"Arn": "arn:aws:kms:ap-northeast-1:111122223333:key/mrk-1234abcd12ab34cd56ef1234567890ab",
8283
"CreationDate": "2021-06-28T21:09:16.114000+00:00",
84+
"CurrentKeyMaterialId": "0b7fd7ddbac6eef27907413567cad8c810e2883dc8a7534067a82ee1142fc1e6",
8385
"Description": "",
8486
"Enabled": true,
8587
"KeyId": "mrk-1234abcd12ab34cd56ef1234567890ab",

awscli/examples/kms/disable-key.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
**To temporarily disable a KMS key**
22

3-
The following example uses the ``disable-key`` command to disable a customer managed KMS key. To re-enable the KMS key, use the ``enable-key`` command. ::
3+
The following ``disable-key`` command disables a customer managed KMS key. To re-enable the KMS key, use the ``enable-key`` command. ::
44

55
aws kms disable-key \
66
--key-id 1234abcd-12ab-34cd-56ef-1234567890ab

awscli/examples/kms/generate-data-key-pair-without-plaintext.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Output::
2020
"PrivateKeyCiphertextBlob": "AQIDAHi6LtupRpdKl2aJTzkK6FbhOtQkMlQJJH3PdtHvS/y+hAFFxmiD134doUDzMGmfCEtcAAAHaTCCB2UGCSqGSIb3DQEHBqCCB1...",
2121
"PublicKey": "MIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIBigKCAYEA3A3eGMyPrvSn7+LdlJE1oUoQV5HpEuHAVbdOyND+NmYDH/mL1OSIEuLrcdZ5hrMH4pk83r40l...",
2222
"KeyId": "arn:aws:kms:us-west-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab",
23+
"KeyMaterialId": "0b7fd7ddbac6eef27907413567cad8c810e2883dc8a7534067a82ee1142fc1e6",
2324
"KeyPairSpec": "ECC_NIST_P384"
2425
}
2526

awscli/examples/kms/generate-data-key-pair.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Output::
1919
"PrivateKeyPlaintext": "MIIG/QIBADANBgkqhkiG9w0BAQEFAASCBucwggbjAgEAAoIBgQDcDd4YzI+u9Kfv4t2UkTWhShBXkekS4cBVt07I0P42ZgMf+YvU5IgS4ut...",
2020
"PublicKey": "MIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIBigKCAYEA3A3eGMyPrvSn7+LdlJE1oUoQV5HpEuHAVbdOyND+NmYDH/mL1OSIEuLrcdZ5hrMH4pk83r40l...",
2121
"KeyId": "arn:aws:kms:us-west-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab",
22+
"KeyMaterialId": "0b7fd7ddbac6eef27907413567cad8c810e2883dc8a7534067a82ee1142fc1e6"
2223
"KeyPairSpec": "RSA_2048"
2324
}
2425

awscli/examples/kms/generate-data-key-without-plaintext.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ Output::
1414

1515
{
1616
"CiphertextBlob": "AQEDAHjRYf5WytIc0C857tFSnBaPn2F8DgfmThbJlGfR8P3WlwAAAH4wfAYJKoZIhvcNAQcGoG8wbQIBADBoBgkqhkiG9w0BBwEwHgYJYIZIAWUDBAEuMBEEDEFogL",
17-
"KeyId": "arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab"
17+
"KeyId": "arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab",
18+
"KeyMaterialId": "0b7fd7ddbac6eef27907413567cad8c810e2883dc8a7534067a82ee1142fc1e6"
1819
}
1920

2021
The ``CiphertextBlob`` (encrypted data key) is returned in base64-encoded format.

awscli/examples/kms/generate-data-key.rst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ Output::
1515
{
1616
"Plaintext": "VdzKNHGzUAzJeRBVY+uUmofUGGiDzyB3+i9fVkh3piw=",
1717
"KeyId": "arn:aws:kms:us-east-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab",
18+
"KeyMaterialId": "0b7fd7ddbac6eef27907413567cad8c810e2883dc8a7534067a82ee1142fc1e6",
1819
"CiphertextBlob": "AQEDAHjRYf5WytIc0C857tFSnBaPn2F8DgfmThbJlGfR8P3WlwAAAH4wfAYJKoZIhvcNAQcGoG8wbQIBADBoBgkqhkiG9w0BBwEwHgYJYIZIAWUDBAEuMBEEDEFogLqPWZconQhwHAIBEIA7d9AC7GeJJM34njQvg4Wf1d5sw0NIo1MrBqZa+YdhV8MrkBQPeac0ReRVNDt9qleAt+SHgIRF8P0H+7U="
1920
}
2021

2122
The ``Plaintext`` (plaintext data key) and the ``CiphertextBlob`` (encrypted data key) are returned in base64-encoded format.
2223

23-
For more information, see `Data keys <https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#data-keys`__ in the *AWS Key Management Service Developer Guide*.
24-
24+
For more information, see `Data keys <https://docs.aws.amazon.com/kms/latest/developerguide/data-keys.html>`__ in the *AWS Key Management Service Developer Guide*.
2525
**Example 2: To generate a 512-bit symmetric data key**
2626

2727
The following ``generate-data-key`` example requests a 512-bit symmetric data key for encryption and decryption. The command returns a plaintext data key for immediate use and deletion, and a copy of that data key encrypted under the specified KMS key. You can safely store the encrypted data key with the encrypted data.
@@ -41,9 +41,10 @@ Output::
4141
{
4242
"CiphertextBlob": "AQIBAHi6LtupRpdKl2aJTzkK6FbhOtQkMlQJJH3PdtHvS/y+hAEnX/QQNmMwDfg2korNMEc8AAACaDCCAmQGCSqGSIb3DQEHBqCCAlUwggJRAgEAMIICSgYJKoZ...",
4343
"Plaintext": "ty8Lr0Bk6OF07M2BWt6qbFdNB+G00ZLtf5MSEb4al3R2UKWGOp06njAwy2n72VRm2m7z/Pm9Wpbvttz6a4lSo9hgPvKhZ5y6RTm4OovEXiVfBveyX3DQxDzRSwbKDPk/...",
44-
"KeyId": "arn:aws:kms:us-west-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab"
44+
"KeyId": "arn:aws:kms:us-west-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab",
45+
"KeyMaterialId": "0b7fd7ddbac6eef27907413567cad8c810e2883dc8a7534067a82ee1142fc1e6"
4546
}
4647

4748
The ``Plaintext`` (plaintext data key) and ``CiphertextBlob`` (encrypted data key) are returned in base64-encoded format.
4849

49-
For more information, see `Data keys <https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#data-keys`__ in the *AWS Key Management Service Developer Guide*.
50+
For more information, see `Data keys <https://docs.aws.amazon.com/kms/latest/developerguide/data-keys.html>`__ in the *AWS Key Management Service Developer Guide*.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
**Example 1: To generate an HMAC for a message**
2+
3+
The following ``generate-mac`` command generates an HMAC for a message, an HMAC KMS key, and a MAC algorithm. The algorithm must be supported by the specified HMAC KMS key.
4+
5+
In AWS CLI v2, the value of the ``message`` parameter must be Base64-encoded. Or, you can save the message in a file and use the ``fileb://`` prefix, which tells the AWS CLI to read binary data from the file.
6+
7+
Before running this command, replace the example key ID with a valid key ID from your AWS account. The key ID must represent a HMAC KMS key with a key usage of ``GENERATE_VERIFY_MAC``. ::
8+
9+
msg=(echo 'Hello World' | base64)
10+
11+
aws kms generate-mac \
12+
--key-id 1234abcd-12ab-34cd-56ef-1234567890ab \
13+
--message fileb://Message \
14+
--mac-algorithm HMAC_SHA_384
15+
16+
Output::
17+
18+
{
19+
"KeyId": "arn:aws:kms:us-west-2:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab",
20+
"Mac": "<HMAC_TAG>",
21+
"MacAlgorithm": "HMAC_SHA_384"
22+
}
23+
24+
For more information about using HMAC KMS keys in AWS KMS, see `HMAC keys in AWS KMS <https://docs.aws.amazon.com/kms/latest/developerguide/hmac.html>`__ in the *AWS Key Management Service Developer Guide*.
25+
26+
**Example 2: To save an HMAC in a file (Linux and macOs)**
27+
28+
The following ``generate-mac`` example generates an HMAC for a short message stored in a local file. The command also gets the ``Mac`` property from the response, Base64-decodes it and saves it in the ExampleMac file. You can use the MAC file in a ``verify-mac`` command that verifies the MAC.
29+
30+
The ``generate-mac`` command requires a Base64-encoded message and a MAC algorithm that your HMAC KMS key supports. To get the MAC algorithms that your KMS key supports, use the ``describe-key`` command.
31+
32+
Before running this command, replace the example key ID with a valid key ID from your AWS account. The key ID must represent an asymmetric KMS key with a key usage of GENERATE_VERIFY_MAC. ::
33+
34+
echo 'hello world' | base64 > EncodedMessage
35+
36+
aws kms generate-mac \
37+
--key-id 1234abcd-12ab-34cd-56ef-1234567890ab \
38+
--message fileb://EncodedMessage \
39+
--mac-algorithm HMAC_SHA_384 \
40+
--output text \
41+
--query Mac | base64 --decode > ExampleMac
42+
43+
This command produces no output. This example extracts the ``Mac`` property of the output and saves it in a file.
44+
45+
For more information about using HMAC KMS keys in AWS KMS, see `HMAC keys in AWS KMS <https://docs.aws.amazon.com/kms/latest/developerguide/hmac.html>`__ in the *AWS Key Management Service Developer Guide*.

awscli/examples/kms/generate-random.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ When you run this command, you must use the ``number-of-bytes`` parameter to spe
66

77
You don't specify a KMS key when you run this command. The random byte string is unrelated to any KMS key.
88

9-
By default, AWS KMS generates the random number. However, if you specify a `custom key store<https://docs.aws.amazon.com/kms/latest/developerguide/custom-key-store-overview.html>`__, the random byte string is generated in the AWS CloudHSM cluster associated with the custom key store.
9+
By default, AWS KMS generates the random number. However, if you specify a `custom key store <https://docs.aws.amazon.com/kms/latest/developerguide/custom-key-store-overview.html>`__, the random byte string is generated in the AWS CloudHSM cluster associated with the custom key store.
1010

1111
This example uses the following parameters and values:
1212

0 commit comments

Comments
 (0)