ApiMcpServerValidateHcl

更新时间:
复制 MD 格式

Validates the syntax of HashiCorp Configuration Language (HCL) for Terraform.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

openapiexplorer:ApiMcpServerValidateHcl

none

*All Resource

*

None None

Request syntax

POST /terraform/validate HTTP/1.1

Request parameters

Parameter

Type

Required

Description

Example

body

object

No

The request body.

code

string

No

The content of the Terraform HCL code. For more information, see HCL language overview.

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 }

Response elements

Element

Type

Description

Example

object

The response.

requestId

string

The request ID.

9BFC4AC1-6BE4-5405-BDEC-CA288D404812

hash

string

The unique identifier of the Terraform HCL code.

0628e13692023222bef9d6377dd03da3304b689e1b2df60f584ea27b4163bf07

isValid

boolean

Indicates whether the code is valid.

true

errors

array

The list of error messages.

string

The content of the error message.

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

The list of warning messages.

string

The content of the warning message.

Warning.

parameters

array

The list of parameters.

any

The content of the parameter.

{ "schema": { "writeOnly": false, "nullable": false, "description": "The name of the VPC to modify.\n\nThe name must be 1 to 128 characters in length and cannot start with `http://` or `https://`.", "readOnly": false, "type": "string", "required": false }, "deprecated": false, "allowEmptyValue": false, "name": "name", "required": false, "example": "terraform-example" }

diagnosticReport

any

The diagnostic report of the code.

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

Examples

Success response

JSON format

{
  "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\": \"The name of the VPC to modify.\\n\\nThe name must be 1 to 128 characters in length and cannot start with `http://` or `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."
}

Error codes

HTTP status code

Error code

Error message

Description

400 InvalidParam.Code Empty code is not valid. The Code parameter is an invalid empty string.
400 Missing.Code Code is mandatory for this action. The required parameter Code is missing.
500 InternalServerError The request has failed due to a temporary failure of the server.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.