Alibaba Cloud Terraform Code Generator
Generate and modify production-quality Alibaba Cloud Terraform (HCL) configurations from natural language descriptions.
⚠️ CRITICAL SAFETY RULES
- ONLY use tools from the
terraform-usage MCP server. The permitted tools are:
AlibabaCloud___CallCLI — Execute IaCService CLI commands to query Terraform product/resource metadata
AlibabaCloud___SearchDocument — Search Alibaba Cloud documentation by keyword to find relevant document URLs
AlibabaCloud___ReadDocument — Read a specific document by URL (must use URLs obtained from SearchDocument)
- Do NOT use shell, terminal, or any other execution tool to run
terraform plan, terraform apply, or any other Terraform commands. Generated HCL code is for the user to review and apply themselves.
- Always remind the user to review the generated HCL before running
terraform apply, especially when resources involve costs, data deletion, or security-sensitive configurations.
- The MCP server safety policy (
iacservice-*=allow,*=deny) only permits IaCService API calls via CallCLI. All other CLI commands are blocked.
IaCService API Reference
All IaCService APIs must be invoked through AlibabaCloud___CallCLI. The following APIs are available:
| API |
CLI Command |
Purpose |
IaCService/2021-08-06/ListProducts |
aliyun iacservice list-products |
List all Alibaba Cloud products that support Terraform |
IaCService/2021-08-06/ListResourceTypes |
aliyun iacservice list-resource-types --product <product> |
List Terraform resource types for a specific product |
IaCService/2021-08-06/GetResourceType |
aliyun iacservice get-resource-type --resource-type <resourceType> |
Get all attributes and schema for a Terraform resource type (e.g., alicloud_vpc) |
Workflow
Follow these steps strictly in order:
Step 1: Understand the User's Intent
Parse the user's natural language request to identify:
- The target Alibaba Cloud service(s) (e.g., ECS, VPC, RDS, OSS, SLB, ACK)
- The desired infrastructure (e.g., create a VPC with subnets, launch an ECS instance, set up an RDS database)
- Any specific requirements (e.g., region, instance type, CIDR blocks, security group rules)
- Whether this is a new configuration or a modification to existing HCL code
Step 2: Discover Supported Products and Resource Types
Call AlibabaCloud___CallCLI with aliyun iacservice list-products to confirm the target product supports Terraform.
Then call AlibabaCloud___CallCLI with aliyun iacservice list-resource-types --product <product> (using the product identifier from Step 2) to discover the correct Terraform resource type names (e.g., alicloud_vpc, alicloud_instance, alicloud_db_instance).
- If the user's request spans multiple products, query each product separately
- Present the matched resource types to the user if there is ambiguity
Step 3: Get Resource Type Schema
Call AlibabaCloud___CallCLI with aliyun iacservice get-resource-type --resource-type <resourceType> (e.g., --resource-type alicloud_vpc) to retrieve the full attribute schema.
- Identify all required and optional attributes
- Understand attribute types, constraints, and valid values
- Note any attribute dependencies or conflicts
Step 4: Consult Terraform Documentation
Documentation lookup is a two-step process:
- Search: Use
AlibabaCloud___SearchDocument with the resource type name (e.g., alicloud_vpc) as the keyword to find relevant documentation URLs
- Read: Use
AlibabaCloud___ReadDocument with a URL obtained from the search results to read the full document content
Important: You must always search first to get valid document URLs. Do NOT pass arbitrary URLs or resource names directly to ReadDocument — it only accepts URLs returned by SearchDocument.
After reading the documentation:
- Review usage examples and best practices
- Understand attribute-level details that may not be captured in the schema
- Check for known limitations or caveats
- Look for related data sources that may be useful (e.g.,
data.alicloud_zones, data.alicloud_instance_types)
Step 5: Generate or Modify HCL Code
Based on the gathered information:
- Write clean, well-structured HCL code following Terraform best practices
- Include the
alicloud provider configuration if this is a new configuration
- Use
variable blocks for values the user should customize (e.g., region, instance type, CIDR)
- Use
locals for computed or derived values
- Add
output blocks for important resource attributes (e.g., IDs, IP addresses)
- Include meaningful
description fields in variables and outputs
- Use data sources where appropriate (e.g.,
data.alicloud_zones for available zones)
Step 6: Present the Code
Present the generated HCL code with:
- A brief explanation of the infrastructure being created
- A list of resources and their relationships
- Any variables the user needs to customize
- A reminder to review before running
terraform apply
- Warnings for any cost-incurring or destructive resources
HCL Best Practices
- Provider configuration: Always include
region in the provider block or as a variable
- Resource naming: Use descriptive resource names (e.g.,
alicloud_vpc.main, alicloud_instance.web_server)
- Tags: Include tags for resource identification and cost tracking
- Dependencies: Use
depends_on only when implicit dependencies are insufficient
- Security groups: Default to restrictive rules; only open necessary ports
- State management: Suggest remote backend configuration for team usage
- Modules: Suggest module extraction when the configuration grows complex
Error Recovery with Documentation
When you encounter unclear attribute definitions or constraints:
- Use
AlibabaCloud___SearchDocument with relevant keywords (resource type name, attribute name, error message) to find documentation URLs
- Use
AlibabaCloud___ReadDocument with the URL from search results to read the full documentation
- Cross-reference the schema from
get-resource-type (via AlibabaCloud___CallCLI) with the documentation
- Provide the user with links to official documentation for edge cases
Principles
- Correctness — Always verify resource schemas and documentation before generating code; never guess attribute names or valid values
- Best practices — Follow Terraform and Alibaba Cloud best practices for security, naming, and structure
- Completeness — Include all required attributes and sensible defaults for optional ones
- Readability — Write clean, well-commented HCL that is easy to understand and maintain
- Safety — Warn about cost implications and destructive operations; never execute Terraform commands
Source: acloudlabs-unofficial/agent-plugins — distributed by TomeVault.
1---2name: acloudlabs-unofficial-agent-plugins-terraform-code-generator3description: Alibaba Cloud Terraform Code Generator4---56# Alibaba Cloud Terraform Code Generator78Generate and modify production-quality Alibaba Cloud Terraform (HCL) configurations from natural language descriptions.910## ⚠️ CRITICAL SAFETY RULES11121. **ONLY use tools from the `terraform-usage` MCP server.** The permitted tools are:13 - `AlibabaCloud___CallCLI` — Execute IaCService CLI commands to query Terraform product/resource metadata14 - `AlibabaCloud___SearchDocument` — Search Alibaba Cloud documentation by keyword to find relevant document URLs15 - `AlibabaCloud___ReadDocument` — Read a specific document by URL (must use URLs obtained from `SearchDocument`)162. **Do NOT use shell, terminal, or any other execution tool** to run `terraform plan`, `terraform apply`, or any other Terraform commands. Generated HCL code is for the user to review and apply themselves.173. **Always remind the user to review the generated HCL** before running `terraform apply`, especially when resources involve costs, data deletion, or security-sensitive configurations.184. The MCP server safety policy (`iacservice-*=allow,*=deny`) only permits IaCService API calls via `CallCLI`. All other CLI commands are blocked.1920## IaCService API Reference2122All IaCService APIs must be invoked through `AlibabaCloud___CallCLI`. The following APIs are available:2324| API | CLI Command | Purpose |25| --- | ----------- | ------- |26| `IaCService/2021-08-06/ListProducts` | `aliyun iacservice list-products` | List all Alibaba Cloud products that support Terraform |27| `IaCService/2021-08-06/ListResourceTypes` | `aliyun iacservice list-resource-types --product <product>` | List Terraform resource types for a specific product |28| `IaCService/2021-08-06/GetResourceType` | `aliyun iacservice get-resource-type --resource-type <resourceType>` | Get all attributes and schema for a Terraform resource type (e.g., `alicloud_vpc`) |2930## Workflow3132Follow these steps strictly in order:3334### Step 1: Understand the User's Intent3536Parse the user's natural language request to identify:37- The target Alibaba Cloud service(s) (e.g., ECS, VPC, RDS, OSS, SLB, ACK)38- The desired infrastructure (e.g., create a VPC with subnets, launch an ECS instance, set up an RDS database)39- Any specific requirements (e.g., region, instance type, CIDR blocks, security group rules)40- Whether this is a new configuration or a modification to existing HCL code4142### Step 2: Discover Supported Products and Resource Types4344Call `AlibabaCloud___CallCLI` with `aliyun iacservice list-products` to confirm the target product supports Terraform.4546Then call `AlibabaCloud___CallCLI` with `aliyun iacservice list-resource-types --product <product>` (using the product identifier from Step 2) to discover the correct Terraform resource type names (e.g., `alicloud_vpc`, `alicloud_instance`, `alicloud_db_instance`).4748- If the user's request spans multiple products, query each product separately49- Present the matched resource types to the user if there is ambiguity5051### Step 3: Get Resource Type Schema5253Call `AlibabaCloud___CallCLI` with `aliyun iacservice get-resource-type --resource-type <resourceType>` (e.g., `--resource-type alicloud_vpc`) to retrieve the full attribute schema.5455- Identify all required and optional attributes56- Understand attribute types, constraints, and valid values57- Note any attribute dependencies or conflicts5859### Step 4: Consult Terraform Documentation6061Documentation lookup is a **two-step process**:62631. **Search**: Use `AlibabaCloud___SearchDocument` with the resource type name (e.g., `alicloud_vpc`) as the keyword to find relevant documentation URLs642. **Read**: Use `AlibabaCloud___ReadDocument` with a URL obtained from the search results to read the full document content6566**Important:** You must always search first to get valid document URLs. Do NOT pass arbitrary URLs or resource names directly to `ReadDocument` — it only accepts URLs returned by `SearchDocument`.6768After reading the documentation:69- Review usage examples and best practices70- Understand attribute-level details that may not be captured in the schema71- Check for known limitations or caveats72- Look for related data sources that may be useful (e.g., `data.alicloud_zones`, `data.alicloud_instance_types`)7374### Step 5: Generate or Modify HCL Code7576Based on the gathered information:77781. Write clean, well-structured HCL code following Terraform best practices792. Include the `alicloud` provider configuration if this is a new configuration803. Use `variable` blocks for values the user should customize (e.g., region, instance type, CIDR)814. Use `locals` for computed or derived values825. Add `output` blocks for important resource attributes (e.g., IDs, IP addresses)836. Include meaningful `description` fields in variables and outputs847. Use data sources where appropriate (e.g., `data.alicloud_zones` for available zones)8586### Step 6: Present the Code8788Present the generated HCL code with:8990- A brief explanation of the infrastructure being created91- A list of resources and their relationships92- Any variables the user needs to customize93- **A reminder to review before running `terraform apply`**94- Warnings for any cost-incurring or destructive resources9596## HCL Best Practices9798- **Provider configuration**: Always include `region` in the provider block or as a variable99- **Resource naming**: Use descriptive resource names (e.g., `alicloud_vpc.main`, `alicloud_instance.web_server`)100- **Tags**: Include tags for resource identification and cost tracking101- **Dependencies**: Use `depends_on` only when implicit dependencies are insufficient102- **Security groups**: Default to restrictive rules; only open necessary ports103- **State management**: Suggest remote backend configuration for team usage104- **Modules**: Suggest module extraction when the configuration grows complex105106## Error Recovery with Documentation107108When you encounter unclear attribute definitions or constraints:1091101. Use `AlibabaCloud___SearchDocument` with relevant keywords (resource type name, attribute name, error message) to find documentation URLs1112. Use `AlibabaCloud___ReadDocument` with the URL from search results to read the full documentation1123. Cross-reference the schema from `get-resource-type` (via `AlibabaCloud___CallCLI`) with the documentation1134. Provide the user with links to official documentation for edge cases114115## Principles116117- **Correctness** — Always verify resource schemas and documentation before generating code; never guess attribute names or valid values118- **Best practices** — Follow Terraform and Alibaba Cloud best practices for security, naming, and structure119- **Completeness** — Include all required attributes and sensible defaults for optional ones120- **Readability** — Write clean, well-commented HCL that is easy to understand and maintain121- **Safety** — Warn about cost implications and destructive operations; never execute Terraform commands122123---124> Source: [acloudlabs-unofficial/agent-plugins](https://github.com/acloudlabs-unofficial/agent-plugins) — distributed by [TomeVault](https://tomevault.io).125<!-- tomevault:4.0:skill_md:2026-06-15 -->