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-243: Fixes a bug for encryption at rest with new parameters #522

Merged
merged 7 commits into from
Aug 26, 2021

Conversation

coderGo93
Copy link
Contributor

@coderGo93 coderGo93 commented Aug 19, 2021

Description

  • Fixes a bug for encryption at rest when it would appear a difference of type
  • Fixes a behavior bug when after terraform plan appeared a diff even there's not changes because of parameter enabled setting with the default when it shouldn't
  • Fixes a bug when the deprecated parameters would appear changes after terraform plan even if you don't use them
  • Added terratest for Upgrade and create the encryption at rest using AWS/Azure/GCP

Tested manually with Aws, GCP and Azure credentials and it worked without appearing changes after terraform plan

Results of Terratest

Upgrades for AWS/GCP/Azure

--- PASS: TestUpgradeEncryptionAtRestAws (56.51s)
PASS
ok      github.com/mongodb/terraform-provider-mongodbatlas/integration-testing  56.519s

--- PASS: TestUpgradeEncryptionAtRestAzure (20.81s)
PASS
ok      github.com/mongodb/terraform-provider-mongodbatlas/integration-testing  20.819s


--- PASS: TestUpgradeEncryptionAtRestGCP (17.07s)
PASS
ok      github.com/mongodb/terraform-provider-mongodbatlas/integration-testing  17.081s

Create for AWS/GCP/Azure

--- PASS: TestResourceEncryptionAtRestAws (33.90s)
PASS
ok      github.com/mongodb/terraform-provider-mongodbatlas/integration-testing  33.914s


--- PASS: TestResourceEncryptionAtRestAzure (11.11s)
PASS
ok      github.com/mongodb/terraform-provider-mongodbatlas/integration-testing  11.120s


--- PASS: TestResourceEncryptionAtRestGCP (11.24s)
PASS
ok      github.com/mongodb/terraform-provider-mongodbatlas/integration-testing  11.251s


Link to any related issue(s):

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
Contributor

@thetonymaster thetonymaster left a comment

Choose a reason for hiding this comment

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

Just some nitpicks

azure_environment = "AZURE"
subscription_id = var.subscription_id
resource_group_name = var.resource_group_name
key_vault_name = var.key_vault_name
Copy link
Contributor

Choose a reason for hiding this comment

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

can we properly format this?

key_identifier = var.key_identifier
secret = var.client_secret
tenant_id = var.tenant_id
}
Copy link
Contributor

Choose a reason for hiding this comment

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

this also needs formatting

resource "mongodbatlas_encryption_at_rest" "test" {
project_id = mongodbatlas_project.test.id

google_cloud_kms = {
Copy link
Contributor

Choose a reason for hiding this comment

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

format this too

@themantissa themantissa requested review from a team and gssbzn and removed request for andreaangiolillo and a team August 24, 2021 20:30
Copy link
Collaborator

@gssbzn gssbzn left a comment

Choose a reason for hiding this comment

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

Left a couple of questions, let's also format those examples as has been requested, I'm merging #529 soon to make sure they are always

@@ -1,12 +1,12 @@
// +build integration
Copy link
Collaborator

Choose a reason for hiding this comment

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

[q] I've been setting up the repo thru the day and going with docs code, is the plan to stop taging integration tests? it seems some are using it and some are not, can we decide on this and updates docs accordingly (some of the docs on how to test reference the use of tags)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, forgot to un comment that part, I have to make another PR with fork because I cannot make changes and push

Copy link
Collaborator

Choose a reason for hiding this comment

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

@coderGo93 can you address this now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure why was added this line but it seems better to delete this line because in GNUMakefile it's already separating from normal tests with make test, the other similar line is in the resource_mongodbatlas_cloud_provider_access_test.go from integrationtesting folder, should I remove the line as well in this PR? @themantissa

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not entirely sure, if you feel it should be removed please do.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

understood and removed, thank you melissa

@@ -323,19 +322,22 @@ func resourceMongoDBAtlasEncryptionAtRestRead(ctx context.Context, d *schema.Res
if len(values2) != 0 {
value := values2[0].(map[string]interface{})
if !counterEmptyValues(value) {
aws, awsOk := d.GetOk("aws_kms")
aws, awsOk := d.GetOk("aws_kms_config")
Copy link
Collaborator

Choose a reason for hiding this comment

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

line 280 says aws_kms are both different things? what's the difference?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The difference between aws_kms and aws_kms_config is the schema, I have to changed that because in new tf it fails to pass the make test because using TypeMap as object is not allowed, it should be used as TypeList with Max items 1

@@ -177,7 +177,7 @@ func resourceMongoDBAtlasEncryptionAtRest() *schema.Resource {
Schema: map[string]*schema.Schema{
"enabled": {
Type: schema.TypeBool,
Optional: true,
Required: true,
Copy link
Collaborator

Choose a reason for hiding this comment

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

[q] would this be a breaking change if I did not set it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed to Required because I re read the docs and the parameter enabled is required

Copy link
Collaborator

Choose a reason for hiding this comment

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

it's probably a silly question from me just making sure if people where not setting it on their files (as it was optional) will start having errors now that's required

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, will rollback to optional then, thank you gustavo

@coderGo93
Copy link
Contributor Author

Will close this PR to create another PR

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, will merge.

@coderGo93 coderGo93 added the run-testacc To run acceptance tests label Aug 26, 2021
@themantissa themantissa merged commit 28c94b0 into master Aug 26, 2021
@themantissa themantissa deleted the INTMDB-243 branch August 26, 2021 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
run-testacc To run acceptance tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants