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

Working example for Atlas-encryptionAtRest-roles with a single tf apply #415

Merged
merged 6 commits into from
Mar 3, 2021

Conversation

zohar-mongo
Copy link
Contributor

Description

Working example for Atlas-encryptionAtRest-roles with a single terraform apply. This is a workaround that overcomes the cycle issue. The existing example has a bug where the iam_assumed_role_arn argument is populated with the var.aws_iam_role_arn variable, which has a default of an empty string.

The output "aws_iam_role_arn" was removed since it's not in use, and it creates confusion.

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

@themantissa
Copy link
Collaborator

@shum @leofigy @coderGo93 can you all let me know your thoughts? A nice PR from one of our CSAs!

curl --user "${var.public_key}:${var.private_key}" -X PATCH --digest \
--header "Accept: application/json" \
--header "Content-Type: application/json" \
"https://cloud.mongodb.com/api/atlas/v1.0/groups/${var.project_id}/cloudProviderAccess/${mongodbatlas_cloud_provider_access.test.role_id}?pretty=true" \
Copy link
Contributor

Choose a reason for hiding this comment

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

pretty cool !

@zohar-mongo zohar-mongo requested a review from leofigy February 18, 2021 10:55
@shum
Copy link
Collaborator

shum commented Feb 18, 2021

Not a TF expert so can't comment on whether this approach is "best practice™️" , but this is a nifty hack to workaround the problem and looks good to me!

@themantissa
Copy link
Collaborator

@zohar-mongo thank you again for knocking this out. Instead of changing the original example I think we should consider spliting it into two. Keep the original as is (though w/ the bug fix here for the unused variables fyi @coderGo93) but actually make it two directories, one called examples/atlas-encryptionAtRest-roles-two-step and examples/atlas-encryptionAtRest-roles-one-step-workaround. Then if we get it to one step without a workaround we add that one. Would you mind doing the rework on that?

@zohar-mongo
Copy link
Contributor Author

@themantissa Sure

@zohar-mongo
Copy link
Contributor Author

@themantissa Updated the pull request per your request :)

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.

Looks good, thank you for knocking this out. There's one artifact (the second-step 2nd directory in the one step example) but we can fix that up post merge. I'll have one of our devs take a look again and double check but this should help a lot for now. Thanks!

@themantissa
Copy link
Collaborator

@coderGo93 or @leofigy can one of you give one more look? I think we'll need to clean up one of the second-step directories (in the copy from the current example) for the one step workaround but we can do that later I think.

@zohar-mongo
Copy link
Contributor Author

@themantissa Thanks, I didn't modify the "second step" folder. From what I understand, this is the next step for configuring the encryption at rest with the role_id we exported in the first step (creating the role_id with the correct iam_assumed_role_arn in one step was the problem)

@themantissa
Copy link
Collaborator

Ah, I follow. We could move the second into one big example I believe @zohar-mongo but we can improve later. Just waiting for one more review from those selected. Thanks!

Copy link
Contributor

@leofigy leofigy left a comment

Choose a reason for hiding this comment

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

LGTM :) , thanks

}
mongodbatlas = {
source = "mongodb/mongodbatlas"
//version = "0.7-dev"
Copy link
Contributor

Choose a reason for hiding this comment

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

just could you remove this comment from here

@themantissa themantissa requested a review from nikhil-mongo March 1, 2021 23:25
@themantissa
Copy link
Collaborator

@nikhil-mongo I'm going to merge this soon but it could use some clean-up potentially. Can you take a look and let me know if you have any concerns before I merge?

Copy link
Collaborator

@nikhil-mongo nikhil-mongo left a comment

Choose a reason for hiding this comment

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

Please look at the below changes and have them done.

@@ -0,0 +1,76 @@

Copy link
Collaborator

Choose a reason for hiding this comment

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

Please remove this extra line.

@@ -0,0 +1,33 @@
variable "public_key" {
description = "The public API key for MongoDB Atlas"
default = ""
Copy link
Collaborator

Choose a reason for hiding this comment

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

The default values passed as an empty string just add more lines and are of no use. @themantissa if you think we can keep it, its ok. Else please remove these as well.

@@ -0,0 +1,36 @@
variable "public_key" {
description = "The public API key for MongoDB Atlas"
default = ""
Copy link
Collaborator

Choose a reason for hiding this comment

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

The default values passed as an empty string just add more lines and are of no use. @themantissa if you think we can keep it, its ok. Else please remove these as well.

@zohar-mongo zohar-mongo requested a review from nikhil-mongo March 3, 2021 10:17
Copy link
Collaborator

@nikhil-mongo nikhil-mongo left a comment

Choose a reason for hiding this comment

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

LGTM. @themantissa if you want those variables to be kept or not, I'm good with both. But this is good to be merged.

@themantissa
Copy link
Collaborator

@nikhil-mongo thank you. We can keep for now and if you'd like to do a bit of clean up later it would be appreciated. Thank you.

@themantissa themantissa merged commit bc3c9ce into mongodb:master Mar 3, 2021
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.

5 participants