博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
HashiCorp Terraform 0.12 新特性抢鲜看:可靠的JSON语法
阅读量:6407 次
发布时间:2019-06-23

本文共 2446 字,大约阅读时间需要 8 分钟。

AUG 23 2018    MARTIN ATKINS

This is the eighth post of the series highlighting new features in Terraform 0.12.

As part of the lead up to the , we are publishing a series of feature preview blog posts. The post this week is on bringing a clear 1:1 mapping between JSON and HCL.

Terraform has accepted JSON as configuration in addition to HCL since version 0.1. However, the implementation of this prior to version 0.12 had many shortcomings. The HCL improvements in Terraform 0.12 include a clear 1:1 mapping between HCL and JSON, including much clearer error messages and support for comments!

These improvements make it easy to work with Terraform using HCL, JSON, or both.

HCL and JSON

Terraform has supported JSON as an alternate configuration format since its initial release in Terraform 0.1. Further, Terraform has supported mixingJSON and HCL configurations within the same module since version 0.1, as well. Both JSON and HCL are important first-class configuration formats for Terraform.

The JSON mapping in prior versions of Terraform had many shortcomings. In some cases, it felt as though JSON didn't feel like a first class solution in the tool. We have always considered JSON a first class input to Terraform and continue to do so, so a big part of Terraform 0.12 was having a clean 1:1 mapping between HCL and JSON, and ensuring every feature of HCL is supported in JSON.

Terraform 0.12 achieves these goals. In future versions of Terraform, we will also support native tooling to convert HCL to JSON and JSON to HCL cleanly (including comments). This gives additional tooling more power in working with Terraform configurations and also enables people to author configurations in whichever language they feel comfortable.

Error Message Improvements

In versions prior to 0.12, the configuration mapping to JSON was only weakly specified in documentation, there were many counter-intuitive mapping behaviors, and there was a tendency to silently ignore misshapen constructs that made debugging difficult.

Terraform 0.12 includes a new JSON configuration implementation that is more robust than prior versions to address these limitations. In particular, the JSON-based configuration decoder produces errors in any cases where the input cannot be mapped exactly onto the expected configuration structure.

The example below shows an invalid configuration the error produced in Terraform 0.12:

转载于:https://blog.51cto.com/13883466/2163793

你可能感兴趣的文章
js数据结构-链表
查看>>
angular权限管理模块实现思路
查看>>
python大佬养成计划----HTML网页设计(表格)
查看>>
ArrayList源码分析
查看>>
Java编程基础18——集合(Set集合)
查看>>
阿里技术人的第一节课,都上些什么?
查看>>
静态编译OpenSSL并作为CMake第三方库
查看>>
caffe源码解析一 —— caffe的安装(CPU-Windows)
查看>>
zabbix 3.2 使用微信企业号报警
查看>>
【spring boot 系列】spring data jpa 全面解析(实践 + 源码分析)
查看>>
缓存为王--深入分布式缓存
查看>>
微信小程序Markdown、HTML解析库(支持wepy)
查看>>
wamp升级php7
查看>>
java8-08-自定义Collector-groupBy
查看>>
初步学习弹性布局
查看>>
异步流程之Promise解析
查看>>
【Java】利用反射获取class中的所有方法
查看>>
Ant Design upload 组件快速配置使用七牛云
查看>>
ionic2踩坑记
查看>>
爱不释手的Ajax
查看>>