Home > Software engineering >  What is the variable type for {"message":"ok"} in terraform
What is the variable type for {"message":"ok"} in terraform

Time:12-22

I'm writing a terraform module for GCP uptime checks and I need to filter {"message":"ok"} in response body.

Need to pass {"message":"ok"} as a variable, but still cannot find the suitable variable type for it.

I tried complex variable types. But issue not resolved yet

CodePudding user response:

I think you can use a map as variable, example :

variable.tf file :

variable "message" {
  description = "Message"
  type = map
  default = {
    "message" = "ok"
  }
}

Display the message value in the outputs.tf file for example :

output "message_value" {
  value = var.message["message"]
}

CodePudding user response:

Thanks all This is resolved by using jsonencode({ "message" : "ok" })

  • Related