-
Notifications
You must be signed in to change notification settings - Fork 190
feat: Supports configuring BYOK encryption on search nodes #3142
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
Changes from all commits
609c9dc
131c195
1c2db30
15794dd
553a98e
209be02
5703f86
e4a7e20
848e772
c9021aa
7f97e3c
dd9371a
08199d2
9331871
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
```release-note:enhancement | ||
resource/mongodbatlas_encryption_at_rest: Adds `enabled_for_search_nodes` attribute | ||
``` | ||
|
||
```release-note:enhancement | ||
data-source/mongodbatlas_encryption_at_rest: Adds `enabled_for_search_nodes` attribute | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,8 @@ import ( | |
"strconv" | ||
"testing" | ||
|
||
"go.mongodb.org/atlas-sdk/v20250219001/admin" | ||
// TODO: update before merging to master: "go.mongodb.org/atlas-sdk/v20250219001/admin" | ||
"github.com/mongodb/atlas-sdk-go/admin" | ||
|
||
"github.com/hashicorp/terraform-plugin-testing/helper/resource" | ||
|
||
|
@@ -27,6 +28,7 @@ func TestMigEncryptionAtRest_basicAWS(t *testing.T) { | |
} | ||
useDatasource = mig.IsProviderVersionAtLeast("1.19.0") // data source introduced in this version | ||
useRequirePrivateNetworking = mig.IsProviderVersionAtLeast("1.28.0") // require_private_networking introduced in this version | ||
useEnabledForSearchNodes = mig.IsProviderVersionAtLeast("1.30.0") // enabled_for_search_nodes introduced in this version | ||
) | ||
|
||
resource.Test(t, resource.TestCase{ | ||
|
@@ -35,13 +37,13 @@ func TestMigEncryptionAtRest_basicAWS(t *testing.T) { | |
Steps: []resource.TestStep{ | ||
{ | ||
ExternalProviders: mig.ExternalProviders(), | ||
Config: acc.ConfigAwsKms(projectID, &awsKms, useDatasource, useRequirePrivateNetworking), | ||
Config: acc.ConfigAwsKms(projectID, &awsKms, useDatasource, useRequirePrivateNetworking, useEnabledForSearchNodes), | ||
Check: resource.ComposeAggregateTestCheckFunc( | ||
acc.CheckEARExists(resourceName), | ||
resource.TestCheckResourceAttr(resourceName, "aws_kms_config.0.enabled", "true"), | ||
), | ||
}, | ||
mig.TestStepCheckEmptyPlan(acc.ConfigAwsKms(projectID, &awsKms, useDatasource, useRequirePrivateNetworking)), | ||
mig.TestStepCheckEmptyPlan(acc.ConfigAwsKms(projectID, &awsKms, useDatasource, useRequirePrivateNetworking, useEnabledForSearchNodes)), | ||
}, | ||
}) | ||
} | ||
|
@@ -135,40 +137,3 @@ func TestMigEncryptionAtRest_basicGCP(t *testing.T) { | |
}, | ||
}) | ||
} | ||
|
||
func TestMigEncryptionAtRest_basicAWS_from_v1_11_0(t *testing.T) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just double checking why this was removed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Full context of this test is here. I think it's a good time to remove the test because 1.11.0 was released August 2023, and we already have migration tests that run with the previous released version |
||
var ( | ||
resourceName = "mongodbatlas_encryption_at_rest.test" | ||
projectID = os.Getenv("MONGODB_ATLAS_PROJECT_EAR_PE_AWS_ID") // to use RequirePrivateNetworking, Atlas Project is required to have FF enabled | ||
|
||
awsKms = admin.AWSKMSConfiguration{ | ||
Enabled: conversion.Pointer(true), | ||
AccessKeyID: conversion.StringPtr(os.Getenv("AWS_ACCESS_KEY_ID")), | ||
SecretAccessKey: conversion.StringPtr(os.Getenv("AWS_SECRET_ACCESS_KEY")), | ||
CustomerMasterKeyID: conversion.StringPtr(os.Getenv("AWS_CUSTOMER_MASTER_KEY_ID")), | ||
Region: conversion.StringPtr(conversion.AWSRegionToMongoDBRegion(os.Getenv("AWS_REGION"))), | ||
RoleId: conversion.StringPtr(os.Getenv("AWS_EAR_ROLE_ID")), | ||
} | ||
useDatasource = mig.IsProviderVersionAtLeast("1.19.0") // data source introduced in this version | ||
useRequirePrivateNetworking = mig.IsProviderVersionAtLeast("1.28.0") // require_private_networking introduced in this version | ||
) | ||
|
||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { acc.PreCheckAwsEnv(t) }, | ||
CheckDestroy: acc.EARDestroy, | ||
Steps: []resource.TestStep{ | ||
{ | ||
ExternalProviders: acc.ExternalProvidersWithAWS("1.11.0"), | ||
Config: acc.ConfigAwsKms(projectID, &awsKms, false, false), | ||
Check: resource.ComposeAggregateTestCheckFunc( | ||
acc.CheckEARExists(resourceName), | ||
resource.TestCheckResourceAttr(resourceName, "project_id", projectID), | ||
resource.TestCheckResourceAttr(resourceName, "aws_kms_config.0.enabled", "true"), | ||
resource.TestCheckResourceAttr(resourceName, "aws_kms_config.0.region", awsKms.GetRegion()), | ||
resource.TestCheckResourceAttr(resourceName, "aws_kms_config.0.role_id", awsKms.GetRoleId()), | ||
), | ||
}, | ||
mig.TestStepCheckEmptyPlan(acc.ConfigAwsKms(projectID, &awsKms, useDatasource, useRequirePrivateNetworking)), | ||
}, | ||
}) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing a unit test here. Not sure if
encryptionAtRestPlan.EnabledForSearchNodes.IsUnknown()
will be handled as expected?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This made me think and I changed the approach a bit here: 7f97e3c
API has a default value (false), so we can have the default in TF aswell, and we will never have that as Unknown/Null making this simpler. Let me know what you think
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like it, this way, removing the attribute will "go back" to the default value and trigger a plan change 👍