ApiMcpServerValidateHcl - 验证 Terraform 的 HCL 语法

验证 Terraform 的 HCL 语法。

调试

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

调试

授权信息

当前API暂无授权信息透出。

请求语法

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. 由于服务器暂时故障,请求失败。

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

变更历史

更多信息,参考变更详情