Validates the syntax of HashiCorp Configuration Language (HCL) for Terraform.
Try it now
Test
RAM authorization
|
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.