【问题标题】:How to convert hcl tf file to json如何将 hcl tf 文件转换为 json
【发布时间】:2021-02-28 03:00:42
【问题描述】:

想要使用节点应用读取 TF 文件。因此我想阅读和解析 hcl 变量声明。有没有办法通过 terraform cli 将 .tf 文件转换为 .tf.json 文件?我试过terraform show -json,但这会输出我的状态而没有变量声明。

【问题讨论】:

    标签: json terraform hcl


    【解决方案1】:

    我认为您应该为此使用专用工具。

    这个出现在谷歌搜索“nodejs hcl Terraform library”中:

    (老实说,我以前从未见过)

    一般性评论 - 解析像 HCL 这样的语言并非易事。

    【讨论】:

      【解决方案2】:

      你应该使用“terraformer

      您可以将它与“-O json”一起使用

      Import current state to Terraform configuration from a provider
      
      Usage:
         import [provider] [flags]
         import [provider] [command]
      
      Available Commands:
        list        List supported resources for a provider
      
      Flags:
        -O, --output string         output format hcl or json (default "hcl")
      

      【讨论】:

        猜你喜欢
        • 2021-08-05
        • 2021-11-25
        • 2018-01-03
        • 1970-01-01
        • 2014-10-26
        • 1970-01-01
        • 2014-11-11
        • 2019-02-23
        • 1970-01-01
        相关资源
        最近更新 更多