Skip to content
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

INTMDB-245: Added an example for encryption at rest using azure with a cluster #566

Merged
merged 2 commits into from
Sep 24, 2021

Conversation

coderGo93
Copy link
Contributor

Description

  • Added a example of using an encryption at rest with a cluster
  • Added more notes related of using implicit dependency and disabling the encryption at rest

Link to any related issue(s):
#518

Type of change:

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • Documentation fix/enhancement

Required Checklist:

  • I have signed the MongoDB CLA
  • I have read the Terraform contribution guidelines
  • I have added tests that prove my fix is effective or that my feature works per HashiCorp requirements
  • I have added any necessary documentation (if appropriate)
  • I have run make fmt and formatted my code

Further comments

Copy link
Collaborator

@themantissa themantissa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added some more info, made some suggested edits, etc.

encryption_at_rest_provider = "AZURE"
}
```
**NOTE** To disable the encryption at rest, all the clusters of the same project must be deleted.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First there's actually two methods. Deleteing all the clusters is one but they can also disable encryption at rest with BYOK by setting encryption_at_rest_provider = "NONE" (see the docs)

This is important enough I'd move it to the top of this docs as an IMPORTANT NOTE. Also edit:
NOTE To disable the encryption at rest with customer key management for a project all existing clusters in the project must first either have encryption at rest for the provider set to none, e.g. encryption_at_rest_provider = "NONE", or be deleted.

resource "mongodbatlas_encryption_at_rest" "default" {
(...)
depends_on = [mongodbatlas_cloud_provider_access_setup.<resource_name>, mongodbatlas_cloud_provider_access_authorization.<resource_name>]
}
```

## Example of encryption at rest with azure and a cluster using its encryption at rest
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we are providing this for Azure but it would be similar for any cloud provider, correct? Also a slight edit for clarity:

Example: Configuring encryption at rest using customer key management in Azure and then creating a cluster

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi melissa, yes it's similar for any cloud provider, understood will make change shortly, thank you

resource "mongodbatlas_encryption_at_rest" "default" {
(...)
depends_on = [mongodbatlas_cloud_provider_access_setup.<resource_name>, mongodbatlas_cloud_provider_access_authorization.<resource_name>]
}
```

## Example of encryption at rest with azure and a cluster using its encryption at rest

**NOTE** Since the cluster wants to use the encryption at rest it should wait for `mongodbatlas_encryption_at_rest` to finish first by using implicit dependency of `project_id`(see the example below).
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Slight edit, I'd remove Note as this is is really general instructions for the example:
The configuration of encryption at rest with customer key management, mongodbatlas_encryption_at_rest, needs to be completed before a cluster is created in the project. Force this wait by using an implicit dependency via project_id as shown in the example below.

Copy link
Collaborator

@themantissa themantissa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

The configuration of encryption at rest with customer key management, `mongodbatlas_encryption_at_rest`, needs to be completed before a cluster is created in the project. Force this wait by using an implicit dependency via `project_id` as shown in the example below.

```terraform
resource "mongodbatlas_encryption_at_rest" "example" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You tested this right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes for the example I tested manually with and without using implicit dependency, without dependency got some issues related to waiting and with dependency I didn't had any issues for creating/destroying.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@coderGo93 did you test the option I noted, setting the clusters to None? We should probably make sure there's no timing issue with that and Terraform as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@themantissa Not like that, will do that and let you know if I had issues or not.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @themantissa , I tested manually again with setting None in cluster, it worked without any issues.
Steps:

  1. Create a encryption then cluster with dependency
  2. Set encryption_at_rest_provider to None in cluster then terraform apply to update
  3. Then destroy the encryption at rest resource without destroying the cluster(setting count = 0 in encryption at rest resource)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done @coderGo93, just what we needed. Thank you

@thetonymaster thetonymaster merged commit 045f03f into master Sep 24, 2021
@thetonymaster thetonymaster deleted the INTMDB-245 branch September 24, 2021 15:34
abner-dou pushed a commit that referenced this pull request Oct 7, 2021
…a cluster (#566)

* added details about encryption at rest using with cluster in docs

* updated docs

Co-authored-by: Edgar Lopez <edgarlopez@pop-os.localdomain>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants