Skip to content

Commit

Permalink
Enable percent encoding password (#281)
Browse files Browse the repository at this point in the history
  • Loading branch information
bcarranza authored Apr 18, 2022
1 parent 896bc7b commit 293be24
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions terraform-modules/aws/mongodb-atlas-user-list/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ terraform {
resource "mongodbatlas_database_user" "this" {
count = length(var.database_users)
username = var.database_users[count.index].username
password = var.enable_aws_secret ? aws_secretsmanager_secret_version.this[count.index].secret_string : var.database_users[count.index].user_password
password = var.enable_aws_secret ? random_password.password[count.index].result : var.database_users[count.index].user_password
project_id = var.mongodbatlas_projectid
auth_database_name = var.database_users[count.index].auth_database_name

Expand Down Expand Up @@ -52,5 +52,5 @@ resource "random_password" "password" {
resource "aws_secretsmanager_secret_version" "this" {
count = var.enable_aws_secret ? length(var.database_users) : 0
secret_id = aws_secretsmanager_secret.this[count.index].id
secret_string = random_password.password[count.index].result
secret_string = var.enable_percent_encoding_password ? urlencode(random_password.password[count.index].result) : random_password.password[count.index].result
}
6 changes: 6 additions & 0 deletions terraform-modules/aws/mongodb-atlas-user-list/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ variable "enable_aws_secret" {
description = "A flag to denote that we will put the password secret into aws secret"
}

variable "enable_percent_encoding_password" {
type = bool
default = false
description = "A flag to denote that we will put the password secret into aws secret in percent encoding according mongodb documentation: https://www.mongodb.com/docs/manual/reference/connection-string/#examples"
}

variable "database_users" {
# type = map(object({
# cidr_block = string
Expand Down

0 comments on commit 293be24

Please sign in to comment.