Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@lgfa29
Forked from sergsoares/main.tf
Last active July 11, 2022 20:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lgfa29/c0233d53075fc0c6cf96affce658b18d to your computer and use it in GitHub Desktop.
Save lgfa29/c0233d53075fc0c6cf96affce658b18d to your computer and use it in GitHub Desktop.
Snippet for use variables as a map
# 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