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

feat(aws-docdb-cluster): enable the ssm parameter store to record the… #77

Conversation

haidargit
Copy link
Contributor

@haidargit haidargit commented Nov 24, 2023

what

In this PR, we can use the Cloud Posse ssm parameter store module to store the documentdb master_password information.

why

The objective behind this PR is to ensure the secure distribution of the docdb cluster's master password within the AWS infrastructure. We can centrally manage and protect sensitive information, increasing operational efficiency.

references

No issue relates to the current improvement.

I have run these required commands.
make init
make readme

Kindly review this PR for documentdb module improvements. Thank you, Cloud Posse Team!

@haidargit haidargit requested review from a team as code owners November 24, 2023 12:30
@kevcube
Copy link
Contributor

kevcube commented Nov 24, 2023

@haidargit i think you should use this module instead of the resource

variables.tf Outdated
Comment on lines 214 to 212
variable "ssm_parameter_type" {
type = string
default = "SecureString"
description = "Type of the ssm parameter. Valid types are String, StringList and SecureString."
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably doesn't need to be a variable, it should not be allowed to store as String

Copy link
Contributor Author

@haidargit haidargit Nov 24, 2023

Choose a reason for hiding this comment

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

okay, will store it as String for the default on this resource. thank you @kevcube

variables.tf Outdated
variable "ssm_parameter_enabled" {
type = bool
default = false
description = "Whether an SSM parameter store value is created to store the key's private key pem."
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
description = "Whether an SSM parameter store value is created to store the key's private key pem."
description = "Whether an SSM parameter store value is created to store the database password."

Copy link
Contributor Author

@haidargit haidargit Nov 24, 2023

Choose a reason for hiding this comment

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

okay @kevcube, i will fix it

@haidargit haidargit force-pushed the feature/enable-ssm-parameter-for-storing-master-password branch from 6808854 to 8fae0e8 Compare November 24, 2023 13:47
@haidargit
Copy link
Contributor Author

Hi @kevcube, i have updated the PR to add the changes, kindly review the code. Thank you

@haidargit haidargit requested a review from kevcube November 24, 2023 13:52
@haidargit haidargit force-pushed the feature/enable-ssm-parameter-for-storing-master-password branch from 8fae0e8 to ff71709 Compare November 24, 2023 13:55
Copy link
Contributor

@kevcube kevcube left a comment

Choose a reason for hiding this comment

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

please enable the ssm param in examples/complete so it gets tested

main.tf Outdated
{
name = format("%s%s", var.ssm_parameter_path_prefix, module.this.id)
value = var.master_password != "" ? var.master_password : random_password.password[0].result
type = "String"
Copy link
Contributor

Choose a reason for hiding this comment

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

Secure

main.tf Outdated
@@ -152,3 +152,20 @@ module "dns_replicas" {

context = module.this.context
}

module "ssm_parameter_store" {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
module "ssm_parameter_store" {
module "ssm_write_db_password" {

variables.tf Outdated
Comment on lines 220 to 224
variable "ssm_parameter_description" {
type = string
default = "documentdb cluster master_password"
description = "Description of the parameter"
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
variable "ssm_parameter_description" {
type = string
default = "documentdb cluster master_password"
description = "Description of the parameter"
}

Copy link
Contributor

Choose a reason for hiding this comment

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

too generic. let's just hardcode description based on cluster's name.

main.tf Outdated
name = format("%s%s", var.ssm_parameter_path_prefix, module.this.id)
value = var.master_password != "" ? var.master_password : random_password.password[0].result
type = "String"
description = var.ssm_parameter_description
Copy link
Contributor

@kevcube kevcube Nov 24, 2023

Choose a reason for hiding this comment

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

Master password for module.this.id DocumentDB cluster

      description = "Master password for ${module.this.id} DocumentDB cluster"

@haidargit haidargit force-pushed the feature/enable-ssm-parameter-for-storing-master-password branch from ff71709 to afff05a Compare November 24, 2023 14:56
@haidargit
Copy link
Contributor Author

Could you help review again, @kevcube ? i have added the changes. Thanks

@kevcube
Copy link
Contributor

kevcube commented Nov 24, 2023

@haidargit see failing checks.

Delete your .terraform.lock.hcl file before running make readme and it should properly generate the README.

@haidargit haidargit force-pushed the feature/enable-ssm-parameter-for-storing-master-password branch from afff05a to 93eebc5 Compare November 24, 2023 15:04
@haidargit haidargit force-pushed the feature/enable-ssm-parameter-for-storing-master-password branch from 93eebc5 to 52840fd Compare November 24, 2023 15:13
@haidargit
Copy link
Contributor Author

Thanks @kevcube! i have removed the lock files and updated the readme. 
could you help check again?

@kevcube
Copy link
Contributor

kevcube commented Nov 24, 2023

/terratest

Copy link
Contributor

@kevcube kevcube left a comment

Choose a reason for hiding this comment

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

thanks for the contribution!

@kevcube kevcube merged commit d0bd143 into cloudposse:main Nov 24, 2023
@haidargit
Copy link
Contributor Author

Thanks Cloud Posse, @kevcube !!

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.

2 participants