Skip to content

Instantly share code, notes, and snippets.

@lukasmrtvy
Created May 22, 2019 15:05
Show Gist options
  • Save lukasmrtvy/c862b786b28c3fd2f455c192e329ff0c to your computer and use it in GitHub Desktop.
Save lukasmrtvy/c862b786b28c3fd2f455c192e329ff0c to your computer and use it in GitHub Desktop.
terraform: random_password
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