Skip to content

Commit fd350e7

Browse files
committed
revamp kms
1 parent 6323d44 commit fd350e7

File tree

1 file changed

+40
-31
lines changed
  • src/content/docs/aws/services

1 file changed

+40
-31
lines changed

src/content/docs/aws/services/kms.md

Lines changed: 40 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
---
22
title: "Key Management Service (KMS)"
3-
linkTitle: "Key Management Service (KMS)"
43
description: Get started with Key Management Service (KMS) on LocalStack
54
persistence: supported
65
tags: ["Free"]
@@ -14,7 +13,7 @@ KMS allows you to create, delete, list, and update aliases, friendly names for y
1413
You can check [the official AWS documentation](https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html) to understand the basic terms and concepts used in the KMS.
1514

1615
LocalStack allows you to use the KMS APIs in your local environment to create, edit, and view symmetric and asymmetric KMS keys, including HMAC keys.
17-
The supported APIs are available on our [API coverage page]({{< ref "coverage_kms" >}}), which provides information on the extent of KMS's integration with LocalStack.
16+
The supported APIs are available on our [API coverage page](), which provides information on the extent of KMS's integration with LocalStack.
1817

1918
## Getting started
2019

@@ -28,24 +27,24 @@ We will demonstrate how to create a simple symmetric encryption key and use it t
2827
To generate a new key within the KMS, you can use the [`CreateKey`](https://docs.aws.amazon.com/kms/latest/APIReference/API_CreateKey.html) API.
2928
Execute the following command to create a new key:
3029

31-
{{< command >}}
32-
$ awslocal kms create-key
33-
{{</ command >}}
30+
```bash
31+
awslocal kms create-key
32+
```
3433

3534
By default, this command generates a symmetric encryption key, eliminating the need for any additional arguments.
3635
You can take a look at the `KeyId` of the freshly generated key in the output, and save it for future use.
3736

3837
In case the key ID is misplaced, it is possible to retrieve a comprehensive list of IDs and [Amazon Resource Names](https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html) (ARNs) for all available keys through the following command:
3938

40-
{{< command >}}
41-
$ awslocal kms list-keys
42-
{{</ command >}}
39+
```bash
40+
awslocal kms list-keys
41+
```
4342

4443
Additionally, if needed, you can obtain extensive details about a specific key by providing its key ID or ARN using the subsequent command:
4544

46-
{{< command >}}
47-
$ awslocal kms describe-key --key-id <KEY_ID>
48-
{{</ command >}}
45+
```bash
46+
awslocal kms describe-key --key-id <KEY_ID>
47+
```
4948

5049
### Encrypt the data
5150

@@ -54,14 +53,14 @@ For instance, let's consider encrypting "_some important stuff_".
5453
To do so, you can use the [`Encrypt`](https://docs.aws.amazon.com/kms/latest/APIReference/API_Encrypt.html) API.
5554
Execute the following command to encrypt the data:
5655

57-
{{< command >}}
58-
$ awslocal kms encrypt \
56+
```bash
57+
awslocal kms encrypt \
5958
--key-id 010a4301-4205-4df8-ae52-4c2895d47326 \
6059
--plaintext "some important stuff" \
6160
--output text \
6261
--query CiphertextBlob \
6362
| base64 --decode > my_encrypted_data
64-
{{</ command >}}
63+
```
6564

6665
You will notice that a new file named `my_encrypted_data` has been created in your current directory.
6766
This file contains the encrypted data, which can be decrypted using the same key.
@@ -74,13 +73,13 @@ However, with asymmetric keys the `KEY_ID` has to be specified.
7473

7574
Execute the following command to decrypt the data:
7675

77-
{{< command >}}
78-
$ awslocal kms decrypt \
76+
```bash
77+
awslocal kms decrypt \
7978
--ciphertext-blob fileb://my_encrypted_data \
8079
--output text \
8180
--query Plaintext \
8281
| base64 --decode
83-
{{</ command >}}
82+
```
8483

8584
Similar to the previous `Encrypt` operation, to retrieve the actual data, it's necessary to decode the Base64-encoded output.
8685
To achieve this, employ the `output` and `query` parameters along with the `base64` tool as before.
@@ -95,9 +94,8 @@ some important stuff
9594
The LocalStack Web Application provides a Resource Browser for managing KMS keys.
9695
You can access the Resource Browser by opening the LocalStack Web Application in your browser, navigating to the **Resources** section, and then clicking on **KMS** under the **Security Identity Compliance** section.
9796

98-
<img src="kms-resource-browser.png" alt="KMS Resource Browser" title="KMS Resource Browser" width="900" />
99-
<br>
100-
<br>
97+
![KMS Resource Browser](/images/aws/kms-resource-browser.png)
98+
10199
The Resource Browser allows you to perform the following actions:
102100

103101
- **Create Key**: Create a new KMS key by specifying the **Policy**, **Key Usage**, **Tags**, **Multi Region**, **Customer Master Key Spec**, and more.
@@ -113,9 +111,9 @@ This can be useful to pre-seed a test environment and use a static `KeyId` for y
113111

114112
Below is a simple example to create a key with a custom `KeyId` (note that the `KeyId` should have the format of a UUID):
115113

116-
{{< command >}}
117-
$ awslocal kms create-key --tags '[{"TagKey":"_custom_id_","TagValue":"00000000-0000-0000-0000-000000000001"}]'
118-
{{< / command >}}
114+
```bash
115+
awslocal kms create-key --tags '[{"TagKey":"_custom_id_","TagValue":"00000000-0000-0000-0000-000000000001"}]'
116+
```
119117

120118
The following output will be displayed:
121119

@@ -135,21 +133,32 @@ This can be useful to pre-seed a development environment so values encrypted wit
135133

136134
Here is an example of using custom key material with the value being base64 encoded:
137135

138-
{{< command >}}
139-
$ echo 'dGhpc2lzYXNlY3VyZWtleQ==' | base64 -d
140-
<disable-copy>
136+
```bash
137+
echo 'dGhpc2lzYXNlY3VyZWtleQ==' | base64 -d
138+
```
139+
140+
The following output will be displayed:
141+
142+
```text
141143
thisisasecurekey
142-
</disable-copy>
143-
$ awslocal kms create-key --tags '[{"TagKey":"_custom_key_material_","TagValue":"dGhpc2lzYXNlY3VyZWtleQ=="}]'
144-
<disable-copy>
144+
```
145+
146+
You can create a key with custom key material using the following command:
147+
148+
```bash
149+
awslocal kms create-key --tags '[{"TagKey":"_custom_key_material_","TagValue":"dGhpc2lzYXNlY3VyZWtleQ=="}]'
150+
```
151+
152+
The following output will be displayed:
153+
154+
```json
145155
{
146156
"KeyMetadata": {
147157
"AWSAccountId": "000000000000",
148158
"KeyId": "00000000-0000-0000-0000-000000000001",
149159
....
150160
}
151-
</disable-copy>
152-
{{< / command >}}
161+
```
153162

154163
## Current Limitations
155164

0 commit comments

Comments
 (0)