【问题标题】:How to comment out a code on VS code terraform如何在 VS Code Terraform 上注释掉一段代码
【发布时间】:2022-12-05 15:40:43
【问题描述】:

我想了解如何在 Terraform 中注释掉 VS 代码上的代码。我是编码和亚马逊网络服务领域的新手。我仍在学习使用 Terraform。

【问题讨论】:

    标签: comments out


    【解决方案1】:

    在 Terraform 中注释掉代码的最常见方法是在行的开头添加一个散列:

    variable "var_1" {
      type    = string
      default = "value-1"
    }
    
    # variable "var_2" {
    #   type    = string
    #   default = "value-2"
    # }
    

    在上面的示例中,Terraform 将创建名为 var_1 的变量,但不会创建名为 var_2 的变量,因为该变量已被注释掉。

    你可以看看Terraform Configuration Syntax

    【讨论】:

      【解决方案2】:

      Attaching the Terraform documentation for commenting

      Terraform 语言支持三种不同的 cmet 语法:

      开始单行注释,结束于行尾。

      // also begins a single-line comment, as an alternative to #. /* and */ are start and end delimiters for a comment that might span over multiple lines. The # single-line comment style is the default comment style and should be used in most cases. Automatic configuration formatting tools may automatically transform // cmets into # cmets, since the double-slash style is not idiomatic.

      【讨论】:

        猜你喜欢
        • 2022-09-23
        • 2011-02-03
        • 2010-10-15
        • 2017-11-24
        • 1970-01-01
        • 2011-08-07
        • 1970-01-01
        • 2011-03-10
        • 2018-11-16
        相关资源
        最近更新 更多