Created
September 4, 2018 21:58
-
-
Save ketzacoatl/0bbdd013ac6cf144403978158e8deee9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
locals { | |
# we have to fixup the master username before we use it, the AWS API will error out otherwise | |
# RDS expects the username to be without hyphens and 16 characters at max. 'rdsadmin' is also | |
# a forbidden username, though we don't validate that here. | |
db_master_user_unsanitized = "${var.app_db_master_user}" | |
# truncate to 16 characters, but deal with the fact that substr() will error out if you ask | |
# for more characters than are in the string | |
default_master_user_max_length = "16" | |
master_user_length = "${length(local.db_master_user_unsanitized)}" | |
master_user_max_length = "${local.master_user_length < local.default_master_user_max_length ? local.master_user_length : local.default_master_user_max_length}" | |
db_master_user_truncated = "${substr(local.db_master_user_unsanitized, 0, local.master_user_max_length)}" | |
# remove hyphens from the username | |
db_master_user = "${replace(local.db_master_user_truncated, "-", "")}" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment