Complete the code to define a JSON variable in Terraform.
variable "config" { type = [1] }
The map(string) type is used to represent JSON objects with string values in Terraform.
Complete the code to parse a JSON string into a Terraform map.
locals {
config_map = jsondecode([1])
}The jsondecode() function expects a JSON string variable, so we pass var.config without quotes.
Fix the error in the JSON configuration by completing the code.
resource "aws_s3_bucket" "example" { bucket = [1] acl = "private" }
The bucket name should be passed as a variable reference var.bucket_name without quotes or decoding.
Fill both blanks to create a JSON object variable and assign a default value.
variable "settings" { type = [1] default = [2] }
The variable type is an object with keys and string types, and the default value is a Terraform map with key-value pairs.
Complete the code to decode a JSON string and access a nested value.
locals {
config = jsondecode([1])
region = config["region"]
}We decode the JSON string variable, then access the 'region' key using square brackets.