简体   繁体   中英

What's the difference between Terraform syntax and format?

According to Terraform docs, the configuration files can be in either of two formats: terraform format and JSON.

Ref. - https://www.terraform.io/docs/configuration/index.html

What exactly is the terraform format? Especially in relation to the Terraform config file syntax: HCL (HashiCorp Configuration Language). Ref. - https://www.terraform.io/docs/configuration/syntax.html

For example, a file could have the JSON format, and the HCL syntax. Or could have the TF format, and the JSON syntax.

Also, what's the difference between a JSON format and JSON syntax?

Terraform uses a proprietary language called HashiCorp Configuration Language (HCL) . This language is stored in .tf files ( =Terraform format ). In these files you can describe your infrastructure and set variables. These definitions of your infrastructure are called a configuration. Therefor HashiCorp calles it configuration syntax to distinguish between configuration syntax (describe infrastructure, use the Terraform objects) and interpolation syntax (insertion of other values (variables, code, etc.) into strings).

Instead using the Terraform syntax (.tf files) you can write the Terraform configuration also in a JSON Syntax , the file ends with .tf.json in this case. The constructs are equal but in JSON format. Think of writing code eg for CloudFormation (or similar descriptive tools). Here you can also choose between YAML and JSON.

I hope that clarifies a bit. It's even harder because HashiCorp does not use the terms always in the same way...

For more information check out or ask: Configuration , Configuration Syntax , Interpolation Syntax

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM