Skip to content

Instantly share code, notes, and snippets.

@sergsoares
Created July 11, 2022 19:25
Show Gist options
  • Save sergsoares/866b7a1405d1ac912a0e0043b58ea6f5 to your computer and use it in GitHub Desktop.
Save sergsoares/866b7a1405d1ac912a0e0043b58ea6f5 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)
try(var.myapp_conf["REPLICAS"], 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment