Created
May 22, 2019 15:05
-
-
Save lukasmrtvy/c862b786b28c3fd2f455c192e329ff0c to your computer and use it in GitHub Desktop.
terraform: random_password
This file contains 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
variable "password" { default = "" } | |
resource "random_string" "string" { | |
length = "12" | |
count = "${var.password == "" ? 1 : 0 }" | |
} | |
locals { | |
pwd = "${ element(concat(random_string.string.*.result, list("")), 0) != "" ? element(concat(random_string.string.*.result, list("")), 0) : var.password }" | |
} | |
output "var" { | |
value = "${local.pwd}" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment