jsonencode

The function that turns a Terraform value, such as a map or list, into a string of JSON text.

In more detail

It saves hand-quoting JSON and always produces valid output, which makes it ideal for policy documents and manifest files. Its partner jsondecode does the reverse, turning JSON text into a Terraform value.

Example

content = jsonencode({ environment = var.environment })

Related terms

Taught in

References

Certification courses