ApiMcpServerValidateHcl - 验证 Terraform 的 HCL 语法

验证 Terraform 的 HCL 语法。

调试

您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。

调试

授权信息

下表是API对应的授权信息,可以在RAM权限策略语句的Action元素中使用,用来给RAM用户或RAM角色授予调用此API的权限。具体说明如下:

  • 操作:是指具体的权限点。

  • 访问级别:是指每个操作的访问级别,取值为写入(Write)、读取(Read)或列出(List)。

  • 资源类型:是指操作中支持授权的资源类型。具体说明如下:

    • 对于必选的资源类型,用前面加 * 表示。

    • 对于不支持资源级授权的操作,用全部资源表示。

  • 条件关键字:是指云产品自身定义的条件关键字。

  • 关联操作:是指成功执行操作所需要的其他权限。操作者必须同时具备关联操作的权限,操作才能成功。

操作

访问级别

资源类型

条件关键字

关联操作

openapiexplorer:ApiMcpServerValidateHcl

none

*全部资源

*

请求语法

POST /terraform/validate HTTP/1.1

请求参数

名称

类型

必填

描述

示例值

body

object

请求 body。

code

string

Terraform HCL 代码内容。HCL 语言概述

variable "name" { default = "terraform-example" } provider "alicloud" { region = "cn-beijing" } resource "alicloud_vpc" "default" { ipv6_isp = "BGP" description = "test" cidr_block = "10.0.0.0/8" vpc_name = var.name enable_ipv6 = true }

返回参数

名称

类型

描述

示例值

object

请求结果。

requestId

string

请求 ID。

9BFC4AC1-6BE4-5405-BDEC-CA288D404812

hash

string

Terraform HCL 代码的唯一标识。

0628e13692023222bef9d6377dd03da3304b689e1b2df60f584ea27b4163bf07

isValid

boolean

代码内容是否有效。

true

errors

array

错误信息列表。

string

错误信息内容。

Unclosed configuration block: There is no closing brace for this block before the end of the file. This may be caused by incorrect brace nesting elsewhere in this file.

warnings

array

警告信息列表。

string

警告信息内容。

Warning.

parameters

array

参数列表。

any

参数内容。

{ "schema": { "writeOnly": false, "nullable": false, "description": "要修改的VPC名称。\n\n名称长度为1~128个字符,不能以`http://`或`https://`开头。", "readOnly": false, "type": "string", "required": false }, "deprecated": false, "allowEmptyValue": false, "name": "name", "required": false, "example": "terraform-example" }

diagnosticReport

any

代码内容的诊断报告。

Argument or block definition required: An argument or block definition is required here.

示例

正常返回示例

JSON格式

{
  "requestId": "\t\n9BFC4AC1-6BE4-5405-BDEC-CA288D404812\n",
  "hash": "0628e13692023222bef9d6377dd03da3304b689e1b2df60f584ea27b4163bf07",
  "isValid": true,
  "errors": [
    "Unclosed configuration block: There is no closing brace for this block before the end of the file. This may be caused by incorrect brace nesting elsewhere in this file."
  ],
  "warnings": [
    "Warning."
  ],
  "parameters": [
    "{\n      \"schema\": {\n        \"writeOnly\": false,\n        \"nullable\": false,\n        \"description\": \"要修改的VPC名称。\\n\\n名称长度为1~128个字符,不能以`http://`或`https://`开头。\",\n        \"readOnly\": false,\n        \"type\": \"string\",\n        \"required\": false\n      },\n      \"deprecated\": false,\n      \"allowEmptyValue\": false,\n      \"name\": \"name\",\n      \"required\": false,\n      \"example\": \"terraform-example\"\n    }"
  ],
  "diagnosticReport": "Argument or block definition required: An argument or block definition is required here."
}

错误码

HTTP status code

错误码

错误信息

描述

400 InvalidParam.Code Empty code is not valid. Code参数为无效的空字符串。
400 Missing.Code Code is mandatory for this action. 缺少必填参数Code。
500 InternalServerError The request has failed due to a temporary failure of the server. 由于服务器暂时故障,请求失败。

访问错误中心查看更多错误码。

变更历史

更多信息,参考变更详情