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

Allows special characters for db password #325

Closed
wants to merge 9 commits into from
Closed
24 changes: 13 additions & 11 deletions modules/database/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
# SPDX-License-Identifier: MPL-2.0

resource "random_string" "postgresql_password" {
length = 128
special = false
length = 128
special = true
min_special = 4
override_special = "+(!]&;$)"
Copy link
Contributor

Choose a reason for hiding this comment

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

❓ Could you please share the reason behind these specific characters for override_special? This looks like a learning opportunity to me.

Copy link
Author

Choose a reason for hiding this comment

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

The override_special setting indicates exactly which special characters to include in the random string that is generated (for example, there is no "@" symbol and so that special char will not be included in the output string).

}

resource "aws_security_group" "postgresql" {
Expand Down Expand Up @@ -59,7 +61,7 @@ resource "aws_db_instance" "postgresql" {
instance_class = var.db_size
password = random_string.postgresql_password.result
# no special characters allowed
username = var.db_username
username = var.db_username

allow_major_version_upgrade = false
apply_immediately = true
Expand All @@ -74,12 +76,12 @@ resource "aws_db_instance" "postgresql" {
max_allocated_storage = 0
multi_az = true
# no special characters allowed
db_name = var.db_name
port = 5432
publicly_accessible = false
skip_final_snapshot = true
storage_encrypted = true
kms_key_id = var.kms_key_arn
storage_type = "gp2"
vpc_security_group_ids = [aws_security_group.postgresql.id]
db_name = var.db_name
port = 5432
publicly_accessible = false
skip_final_snapshot = true
storage_encrypted = true
kms_key_id = var.kms_key_arn
storage_type = "gp2"
vpc_security_group_ids = [aws_security_group.postgresql.id]
}
Loading