Skip to content

Commit 289053b

Browse files
authored
(DOCSP-46242): Add BYOK Encryption examples (#76)
* initial draft * add link to complete examples * update structure, add context
1 parent d9a02da commit 289053b

8 files changed

+215
-54
lines changed

source/data-encryption.txt

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ OpenSSL :abbr:`FIPS (Federal Information Processing Standards)` Object Module.
3838
:figwidth: 750px
3939
:alt: An image showing encryption in transit with TLS between client applications and MongoDB Atlas.
4040

41+
.. _arch-center-encryption-at-rest:
42+
4143
Encryption at Rest
4244
~~~~~~~~~~~~~~~~~~
4345

@@ -49,17 +51,17 @@ disk encryption, with the provider managing the encryption keys.
4951
This process cannot be disabled.
5052

5153
Additionally, you have the option to enable database-level encryption
52-
by "bringing your own key" (BYOK) with a key management service (KMS).
54+
by **"bringing your own key" (BYOK)** with a key management service (KMS)
55+
such as AWS KMS, Google Cloud KMS, or Azure Key Vault.
5356
|byok| encryption adds another layer of security for additional
5457
confidentiality and data segmentation:
5558

5659
.. figure:: /includes/images/byok-encryption.svg
5760
:figwidth: 750px
5861
:alt: An image showing encryption at rest with an additional customer-managed key.
5962

60-
To learn more about using your own encryption keys with
61-
AWS Key Management Service (KMS), Google Cloud KMS, or
62-
Azure Key Vault, see :ref:`security-kms-encryption`.
63+
To learn more about using your own encryption keys
64+
with a key management service (KMS), see :ref:`security-kms-encryption`.
6365

6466
Encryption in Use
6567
~~~~~~~~~~~~~~~~~
@@ -128,19 +130,22 @@ Recommendations for Data Encryption
128130
Consider the following security recommendations when
129131
provisioning your {+clusters+}.
130132

133+
.. _arch-center-byok:
134+
131135
BYOK Encryption
132136
~~~~~~~~~~~~~~~
133137

134-
For staging and production environments, we recommend that you enable :ref:`BYOK
135-
encryption <security-kms-encryption>` through AWS Key Management Service (KMS),
136-
Google Cloud KMS, or Azure Key Vault when provisioning your {+clusters+}
137-
to avoid relying on application development teams to configure it later on.
138-
This also ensures consistent data protection across your environments.
138+
.. include:: /includes/byok-encryption-recommendations.rst
139+
140+
Use the following methods to enable |byok| encryption:
141+
142+
- :atlas:`{+atlas-ui+} </security-kms-encryption>`
143+
- :oas-atlas-tag:`{+atlas-admin-api+} </Encryption-at-Rest-using-Customer-Key-Management>`
144+
- `Terraform <https://registry.terraform.io/providers/mongodb/mongodbatlas/latest/docs/resources/encryption_at_rest>`__
139145

140-
For development and testing environments, consider skipping |byok| encryption
141-
to save costs. However, if you're storing sensitive data in |service|,
142-
such as for healthcare or financial services industries, consider enabling
143-
|byok| encryption in development and testing environments as well.
146+
To learn how to configure |byok| encryption
147+
when provisioning a new |service| organization, project, and {+cluster+},
148+
see :ref:`arch-center-create-hierarchy-example`.
144149

145150
Data Classification
146151
~~~~~~~~~~~~~~~~~~~

source/hierarchy.txt

Lines changed: 100 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ security settings and governance for your {+service+} enterprise estate:
7878
:align: center
7979
:lightbox:
8080

81+
.. _arch-center-recommendations:
82+
8183
Recommendations
8284
~~~~~~~~~~~~~~~
8385

@@ -114,7 +116,15 @@ projects and {+clusters+}:
114116
- The back end for your application that is live for your
115117
end users.
116118

117-
For your dev and test environments, you can develop {+service+}
119+
BYOK Encryption
120+
```````````````
121+
122+
.. include:: /includes/byok-encryption-recommendations.rst
123+
124+
Local {+service+} Deployments
125+
`````````````````````````````
126+
127+
For your dev and test environments, you can also develop {+service+}
118128
{+clusters+} locally with the {+atlas-cli+}. This can enable developers
119129
to work locally from their machine and cut down on costs for
120130
development and test environments. To learn more, see
@@ -314,6 +324,8 @@ them, see the {+service+} documentation for each cloud provider:
314324
- :atlas:`Azure </reference/microsoft-azure/>`
315325
- :atlas:`{+gcp+} </reference/google-gcp/>`
316326

327+
.. _arch-center-create-hierarchy-example:
328+
317329
Examples
318330
--------
319331

@@ -384,6 +396,17 @@ These examples also apply other recommended configurations, including:
384396

385397
- :ref:`atlas-projects-list`
386398

399+
Configure BYOK Encryption
400+
~~~~~~~~~~~~~~~~~~~~~~~~~
401+
402+
.. include:: /includes/byok-encryption-recommendations-short.rst
403+
404+
You can't manage |byok| encryption with the {+atlas-cli+}.
405+
Use the following methods to configure |byok| encryption:
406+
407+
- :atlas:`{+atlas-ui+} </security-kms-encryption>`
408+
- :oas-atlas-tag:`{+atlas-admin-api+} </Encryption-at-Rest-using-Customer-Key-Management>`
409+
387410
Create One {+Cluster+} Per Project
388411
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
389412

@@ -415,7 +438,7 @@ These examples also apply other recommended configurations, including:
415438
see :ref:`atlas-clusters-create`.
416439

417440
.. tab:: Terraform
418-
:tabid: Terraform
441+
:tabid: tf
419442

420443
.. note::
421444

@@ -468,29 +491,6 @@ These examples also apply other recommended configurations, including:
468491

469492
.. include:: /includes/examples/tf-example-provider.rst
470493

471-
After you create the files, navigate to each application and environment pair's directory and run the following
472-
command to initialize Terraform:
473-
474-
.. code-block::
475-
476-
terraform init
477-
478-
Run the following command to view the Terraform plan:
479-
480-
.. code-block::
481-
482-
terraform plan
483-
484-
Run the following command to create one project and one deployment for the application and environment pair. The command uses the files and the |service-terraform| to
485-
create the projects and clusters:
486-
487-
.. code-block::
488-
489-
terraform apply
490-
491-
When prompted, type ``yes`` and press :kbd:`Enter` to apply
492-
the configuration.
493-
494494
.. tab:: Staging and Prod Environments
495495
:tabid: stagingprod
496496

@@ -518,33 +518,92 @@ These examples also apply other recommended configurations, including:
518518
```````````
519519

520520
.. include:: /includes/examples/tf-example-provider.rst
521+
522+
For more configuration options and info about this example,
523+
see |service-terraform| and the `MongoDB Terraform Blog Post
524+
<https://www.mongodb.com/developer/products/atlas/deploy-mongodb-atlas-terraform-aws/>`__.
521525

522-
After you create the files, navigate to each application and environment pair's directory and run the following
523-
command to initialize Terraform:
526+
Configure BYOK Encryption
527+
~~~~~~~~~~~~~~~~~~~~~~~~~
524528

525-
.. code-block::
529+
.. tabs::
526530

527-
terraform init
531+
.. tab:: Dev and Test Environments
532+
:tabid: devtest
528533

529-
Run the following command to view the Terraform plan:
534+
For your development and testing environments, consider skipping |byok| encryption
535+
environments to save costs, unless you're in a highly-regulated industry
536+
or storing sensitive data. To learn more, see :ref:`arch-center-recommendations`.
530537

531-
.. code-block::
538+
.. tab:: Staging and Prod Environments
539+
:tabid: stagingprod
532540

533-
terraform plan
534-
535-
Run the following command to create one project and one deployment for the application and environment pair. The command uses the files and the |service-terraform| to
536-
create the projects and clusters:
541+
For your staging and production environments environments, we
542+
recommend enabling |byok| encryption when provisioning your {+clusters+}.
543+
To learn more, see :ref:`arch-center-recommendations`.
537544

538-
.. code-block::
545+
To enable |byok| encryption with Terraform,
546+
create the following resources. Change the IDs and names to use your values:
539547

540-
terraform apply
548+
.. tabs::
549+
550+
.. tab:: AWS
551+
:tabid: aws
552+
553+
.. tip::
554+
555+
For a complete configuration example, see
556+
:github:`Atlas Terraform Provider Example <mongodb/terraform-provider-mongodbatlas/blob/master/examples/mongodbatlas_encryption_at_rest/aws/atlas-cluster>`.
557+
558+
Alternatively, to simplify the configuration process, you can use the
559+
`encryption at rest Terraform module <https://registry.terraform.io/modules/terraform-mongodbatlas-modules/encryption-at-rest/mongodbatlas/latest>`__.
560+
561+
.. include:: /includes/examples/tf-example-byok-aws.rst
562+
563+
.. tab:: Azure
564+
:tabid: azure
565+
566+
.. tip::
567+
568+
For a complete configuration example, see
569+
:github:`Atlas Terraform Provider Example <mongodb/terraform-provider-mongodbatlas/tree/master/examples/mongodbatlas_encryption_at_rest/azure>`.
541570

542-
When prompted, type ``yes`` and press :kbd:`Enter` to apply
543-
the configuration.
571+
.. include:: /includes/examples/tf-example-byok-azure.rst
572+
573+
.. tab:: GCP
574+
:tabid: gcp
575+
576+
.. include:: /includes/examples/tf-example-byok-gcp.rst
544577

545578
For more configuration options and info about this example,
546-
see |service-terraform| and the `MongoDB Terraform Blog Post
547-
<https://www.mongodb.com/developer/products/atlas/deploy-mongodb-atlas-terraform-aws/>`__.
579+
see `Terraform documentation
580+
<https://registry.terraform.io/providers/mongodb/mongodbatlas/latest/docs/resources/encryption_at_rest>`__.
581+
582+
Create the Projects and Deployments
583+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
584+
585+
After you create the files, navigate to each application and environment pair's directory and run the following
586+
command to initialize Terraform:
587+
588+
.. code-block::
589+
590+
terraform init
591+
592+
Run the following command to view the Terraform plan:
593+
594+
.. code-block::
595+
596+
terraform plan
597+
598+
Run the following command to create one project and one deployment for the application and environment pair. The command uses the files and the |service-terraform| to
599+
create the projects and clusters:
600+
601+
.. code-block::
602+
603+
terraform apply
604+
605+
When prompted, type ``yes`` and press :kbd:`Enter` to apply
606+
the configuration.
548607

549608
Next Steps
550609
----------
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
For staging and production environments, we
2+
recommend enabling |byok| encryption when provisioning your {+clusters+}.
3+
For development and testing, consider skipping |byok| encryption
4+
environments to save costs, unless you're in a highly-regulated industry
5+
or storing sensitive data. To learn more, see :ref:`arch-center-recommendations`.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
You enable :ref:`BYOK encryption <arch-center-encryption-at-rest>` at the project level.
3+
Once enabled, it automatically applies to all {+clusters+} created within the project,
4+
ensuring consistent data protection across your environment.
5+
6+
For **staging and production environments**, we recommend that you
7+
enable |byok| encryption when provisioning your {+clusters+}
8+
to avoid relying on application development teams to configure it later on.
9+
10+
For **development and testing environments**, consider skipping |byok| encryption
11+
to save costs. However, if you're storing sensitive data in |service|,
12+
such as for healthcare or financial services industries, consider enabling
13+
|byok| encryption in development and testing environments as well.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
.. code-block::
2+
:copyable: true
3+
4+
resource "mongodbatlas_cloud_provider_access_setup" "setup_only" {
5+
project_id = var.atlas_project_id
6+
provider_name = "AWS"
7+
}
8+
9+
resource "mongodbatlas_cloud_provider_access_authorization" "auth_role" {
10+
project_id = var.atlas_project_id
11+
role_id = mongodbatlas_cloud_provider_access_setup.setup_only.role_id
12+
13+
aws {
14+
iam_assumed_role_arn = aws_iam_role.test_role.arn
15+
}
16+
}
17+
18+
resource "mongodbatlas_encryption_at_rest" "test" {
19+
project_id = var.atlas_project_id
20+
21+
aws_kms_config {
22+
enabled = true
23+
customer_master_key_id = aws_kms_key.kms_key.id
24+
region = var.atlas_region
25+
role_id = mongodbatlas_cloud_provider_access_authorization.auth_role.role_id
26+
}
27+
}
28+
29+
data "mongodbatlas_encryption_at_rest" "test" {
30+
project_id = mongodbatlas_encryption_at_rest.test.project_id
31+
}
32+
33+
output "is_aws_kms_encryption_at_rest_valid" {
34+
value = data.mongodbatlas_encryption_at_rest.test.aws_kms_config.valid
35+
}
36+
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
.. code-block::
2+
:copyable: true
3+
4+
resource "mongodbatlas_encryption_at_rest" "test" {
5+
project_id = var.atlas_project_id
6+
7+
azure_key_vault_config {
8+
enabled = true
9+
azure_environment = "AZURE"
10+
11+
tenant_id = var.azure_tenant_id
12+
subscription_id = var.azure_subscription_id
13+
client_id = var.azure_client_id
14+
secret = var.azure_client_secret
15+
16+
resource_group_name = var.azure_resource_group_name
17+
key_vault_name = var.azure_key_vault_name
18+
key_identifier = var.azure_key_identifier
19+
}
20+
}
21+
22+
data "mongodbatlas_encryption_at_rest" "test" {
23+
project_id = mongodbatlas_encryption_at_rest.test.project_id
24+
}
25+
26+
output "is_azure_encryption_at_rest_valid" {
27+
value = data.mongodbatlas_encryption_at_rest.test.azure_key_vault_config.valid
28+
}
29+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
.. code-block::
2+
:copyable: true
3+
4+
resource "mongodbatlas_encryption_at_rest" "test" {
5+
project_id = var.atlas_project_id
6+
7+
google_cloud_kms_config {
8+
enabled = true
9+
service_account_key = "{\"type\": \"service_account\",\"project_id\": \"my-project-common-0\",\"private_key_id\": \"e120598ea4f88249469fcdd75a9a785c1bb3\",\"private_key\": \"-----BEGIN PRIVATE KEY-----\\nMIIEuwIBA(truncated)SfecnS0mT94D9\\n-----END PRIVATE KEY-----\\n\",\"client_email\": \"[email protected]\",\"client_id\": \"10180967717292066\",\"auth_uri\": \"https://accounts.google.com/o/oauth2/auth\",\"token_uri\": \"https://accounts.google.com/o/oauth2/token\",\"auth_provider_x509_cert_url\": \"https://www.googleapis.com/oauth2/v1/certs\",\"client_x509_cert_url\": \"https://www.googleapis.com/robot/v1/metadata/x509/my-email-kms-0%40my-project-common-0.iam.gserviceaccount.com\"}"
10+
key_version_resource_id = "projects/my-project-common-0/locations/us-east4/keyRings/my-key-ring-0/cryptoKeys/my-key-0/cryptoKeyVersions/1"
11+
}
12+
}
13+

source/includes/shared-settings-clusters-stagingprod.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
- Cluster tier set to ``M30`` for a medium-sized application. Use the
22
:ref:`cluster size guide <arch-center-cluster-size-guide>` to learn
33
the recommended cluster tier for your application size.
4+
- Encryption at rest with customer-managed keys (|byok|) enabled.
45

56
Our examples use |aws|, |azure|, and {+gcp+}
67
interchangeably. You can use any of these three cloud providers, but

0 commit comments

Comments
 (0)