You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/docs/aws/services/kms.md
+40-31Lines changed: 40 additions & 31 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,5 @@
1
1
---
2
2
title: "Key Management Service (KMS)"
3
-
linkTitle: "Key Management Service (KMS)"
4
3
description: Get started with Key Management Service (KMS) on LocalStack
5
4
persistence: supported
6
5
tags: ["Free"]
@@ -14,7 +13,7 @@ KMS allows you to create, delete, list, and update aliases, friendly names for y
14
13
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.
15
14
16
15
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.
18
17
19
18
## Getting started
20
19
@@ -28,24 +27,24 @@ We will demonstrate how to create a simple symmetric encryption key and use it t
28
27
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.
29
28
Execute the following command to create a new key:
30
29
31
-
{{< command >}}
32
-
$ awslocal kms create-key
33
-
{{</ command >}}
30
+
```bash
31
+
awslocal kms create-key
32
+
```
34
33
35
34
By default, this command generates a symmetric encryption key, eliminating the need for any additional arguments.
36
35
You can take a look at the `KeyId` of the freshly generated key in the output, and save it for future use.
37
36
38
37
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:
39
38
40
-
{{< command >}}
41
-
$ awslocal kms list-keys
42
-
{{</ command >}}
39
+
```bash
40
+
awslocal kms list-keys
41
+
```
43
42
44
43
Additionally, if needed, you can obtain extensive details about a specific key by providing its key ID or ARN using the subsequent command:
45
44
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
+
```
49
48
50
49
### Encrypt the data
51
50
@@ -54,14 +53,14 @@ For instance, let's consider encrypting "_some important stuff_".
54
53
To do so, you can use the [`Encrypt`](https://docs.aws.amazon.com/kms/latest/APIReference/API_Encrypt.html) API.
55
54
Execute the following command to encrypt the data:
56
55
57
-
{{< command >}}
58
-
$ awslocal kms encrypt \
56
+
```bash
57
+
awslocal kms encrypt \
59
58
--key-id 010a4301-4205-4df8-ae52-4c2895d47326 \
60
59
--plaintext "some important stuff" \
61
60
--output text \
62
61
--query CiphertextBlob \
63
62
| base64 --decode > my_encrypted_data
64
-
{{</ command >}}
63
+
```
65
64
66
65
You will notice that a new file named `my_encrypted_data` has been created in your current directory.
67
66
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.
74
73
75
74
Execute the following command to decrypt the data:
76
75
77
-
{{< command >}}
78
-
$ awslocal kms decrypt \
76
+
```bash
77
+
awslocal kms decrypt \
79
78
--ciphertext-blob fileb://my_encrypted_data \
80
79
--output text \
81
80
--query Plaintext \
82
81
| base64 --decode
83
-
{{</ command >}}
82
+
```
84
83
85
84
Similar to the previous `Encrypt` operation, to retrieve the actual data, it's necessary to decode the Base64-encoded output.
86
85
To achieve this, employ the `output` and `query` parameters along with the `base64` tool as before.
@@ -95,9 +94,8 @@ some important stuff
95
94
The LocalStack Web Application provides a Resource Browser for managing KMS keys.
96
95
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.
0 commit comments