-
-
Save lgfa29/c0233d53075fc0c6cf96affce658b18d to your computer and use it in GitHub Desktop.
Snippet for use variables as a map
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
# variables.tf | |
variable "myapp_conf" { | |
type = map | |
} | |
# terraform.tfvars | |
myapp_conf = { | |
REPLICAS = 0 | |
LIMIT_CPU = "50m" | |
LIMIT_MEMORY = "96Mi" | |
REQUEST_CPU = "50m" | |
REQUEST_MEMORY = "96Mi" | |
SECRET_NAME = "my-app-secret" | |
ENV_VARS = { | |
ENV = "dev" | |
} | |
} | |
# main.tf | |
var.myapp_conf["REPLICAS"] | |
# main.tf (with default) | |
locals { | |
myapp_conf_default = { | |
REPLICAS = 1 | |
} | |
} | |
try(var.myapp_conf["REPLICAS"], local.myapp_conf_default["REPLICAS"]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment