-
Notifications
You must be signed in to change notification settings - Fork 253
feat(tutorial): add tutorial to store sse-c key into secret manager #5677
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+125
−0
Merged
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
188a8b7
feat(tutorial): add tutorial to store sse-c key into secret manager
luxifer f424f9a
fix(tutorial): change command in sse-c tutorial
luxifer e7a10d0
fix(tutorial): doc review 1
SamyOubouaziz 0d3fae7
fix(tutorial): doc review 2
SamyOubouaziz 11606c3
docs: split commands in ordered list with dedicated comments
luxifer b41bf84
docs(review): test and review of tuto
nerda-codes 3031c82
Update tutorials/object-storage-sse-c-with-secret-manager/index.mdx
nerda-codes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
79 changes: 79 additions & 0 deletions
79
tutorials/object-storage-sse-c-with-secret-manager/index.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| --- | ||
| meta: | ||
| title: Using Secret Manager to store encryption key for SSE-C | ||
| description: Learn how to use Secret Manager to store encryption key for Object Storage and SSE-C. | ||
| content: | ||
| h1: Using Secret Manager to store encryption key for SSE-C | ||
| paragraph: Learn how to use Secret Manager to store encryption key for Object Storage and SSE-C. | ||
| tags: object-storage secret-manager encryption | ||
| categories: | ||
| - object-storage | ||
| - secret-manager | ||
| - key-manager | ||
| dates: | ||
| validation: 2025-10-15 | ||
| posted: 2025-10-15 | ||
| --- | ||
| import Requirements from '@macros/iam/requirements.mdx' | ||
|
|
||
| In this tutorial you'll learn how to use the Secret manager to store the encryption key used with [SSE-C](/object-storage/api-cli/enable-sse-c/). | ||
|
|
||
| <Requirements /> | ||
nerda-codes marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| - A Scaleway account logged into the [console](https://console.scaleway.com) | ||
| - [Owner](/iam/concepts/#owner) status or [IAM permissions](/iam/concepts/#permission) allowing you to perform actions in the intended Organization | ||
| - An [Object Storage bucket](/object-storage/how-to/create-a-bucket/) | ||
| - Installed and initialized the [AWS CLI](/object-storage/api-cli/object-storage-aws-cli/) | ||
|
|
||
| The goal here, is to use the Key Manager to generate the encryption key, store the encryption key in the Secret Manager, then use it for Object Storage SSE-C. | ||
|
|
||
| ### Generating the encryption key | ||
|
|
||
| With the following commands, you will create a key in the Key Manager, generate the encryption key and then store it in the Secret Manager. | ||
|
|
||
| ```bash | ||
| KEY_ID=$(scw keymanager key create -o template="{{.ID}}") | ||
luxifer marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| scw keymanager key generate-data-key "$KEY_ID" -o json | jq -r .plaintext | base64 -d > ssec.key | ||
| SECRET_ID=$(scw secret secret create name=ssec-key path=/keys -o template="{{.ID}}") | ||
| scw secret version create "$SECRET_ID" data="@ssec.key" | ||
| ``` | ||
|
|
||
| ### Encryption key and digest preparation | ||
|
|
||
| First you access the secret version to get the encryption key, then you need to encode it to base64 and calculate the digest of the key, also encoded in base64. | ||
|
|
||
| ```bash | ||
| scw secret version access "$SECRET_ID" revision=latest raw=true > ssec.key | ||
| ENCRYPTION_KEY=$(cat ssec.key | base64) | ||
| KEY_DIGEST=$(openssl dgst -md5 -binary ssec.key | base64) | ||
| ``` | ||
|
|
||
| <Message type="important"> | ||
| If you delete the secret containing the encryption key, you also lose the data encrypted with it, as you will not be able to perform `GET` operations on encrypted objects without the corresponding key. | ||
| </Message> | ||
|
|
||
| ### Upload and download object with SSE-C | ||
|
|
||
| Run the command below to upload an object and encrypt it. Make sure to replace `<your-bucket-name>`, `<your-object-key>`, and `<path/to/your/file>` with the correct values. | ||
|
|
||
| ```bash | ||
| aws s3api put-object \ | ||
| --bucket <your-bucket-name> \ | ||
| --key <your-object-key> \ | ||
| --body <path/to/your/file> \ | ||
| --sse-customer-algorithm AES256 \ | ||
| --sse-customer-key $ENCRYPTION_KEY \ | ||
| --sse-customer-key-md5 $KEY_DIGEST | ||
| ``` | ||
|
|
||
| Run the command below to download the previously uploaded object and decrypt it. Make sure to replace `<your-bucket-name>`, `<your-object-key>`, and `<path/to/destination/file>` with the correct values. | ||
|
|
||
| ```bash | ||
| aws s3api get-object \ | ||
| --bucket <your-bucket-name> \ | ||
| --key <your-object-key> \ | ||
| <path/to/destination/file> \ | ||
| --sse-customer-algorithm AES256 \ | ||
| --sse-customer-key $ENCRYPTION_KEY \ | ||
| --sse-customer-key-md5 $KEY_DIGEST | ||
| ``` | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.