> For the complete documentation index, see [llms.txt](https://docs.icraft.design/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.icraft.design/editor-features/navigation-bar/labs/terraform-visualization.md).

# Terraform Visualization

iCraft supports **Terraform visualization**, allowing you to quickly generate, configure, and connect 3D scene elements by writing declarative HCL (HashiCorp Configuration Language) code.

This feature helps transform Infrastructure as Code (IaC) resources, modules, and dependencies into intuitive 3D visual representations. You can view, adjust, and present infrastructure architecture directly on the 3D canvas.

#### Key Features

* **From Code to Visualization**\
  Simply paste or import HCL code, and the system will automatically generate a 3D visualization of resource nodes and their relationships.
* **Two Creation Modes**\
  Support "**Clear and Create"** and "**Incremental Creation",**&#x6D;aking it easy to rebuild or iteratively update the scene.
* **Semantic Mapping**\
  Maps semantics such as `resource`, `module`, `data`, `variable`, and `output` to visual elements including objects, groups, tags, and connections, helping you understand topology and dependencies.
* **Fast presentation and review**\
  Can be used as visual material for architecture review, operation training, and delivery demonstrations.
* **HCL Structure Compatibility**\
  Supports common Terraform HCL syntax structures, enabling seamless integration with existing IaC projects.

***

## Syntax

<https://developer.hashicorp.com/terraform>

***

## Example

**HCL codes**

{% code lineNumbers="true" fullWidth="false" expandable="true" %}

```
terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 5.0"
    }
  }
}

provider "aws" {
  region = "us-west-2"
}

resource "aws_vpc" "main" {
  cidr_block           = "10.0.0.0/16"
  enable_dns_hostnames = true
  enable_dns_support   = true

  tags = {
    Name = "main-vpc"
  }
}

resource "aws_internet_gateway" "main" {
  vpc_id = aws_vpc.main.id

  tags = {
    Name = "main-igw"
  }
}

resource "aws_subnet" "public" {
  vpc_id                  = aws_vpc.main.id
  cidr_block              = "10.0.1.0/24"
  availability_zone       = "us-west-2a"
  map_public_ip_on_launch = true

  tags = {
    Name = "public-subnet"
  }
}

resource "aws_route_table" "public" {
  vpc_id = aws_vpc.main.id

  route {
    cidr_block = "0.0.0.0/0"
    gateway_id = aws_internet_gateway.main.id
  }

  tags = {
    Name = "public-rt"
  }
}

resource "aws_route_table_association" "public" {
  subnet_id      = aws_subnet.public.id
  route_table_id = aws_route_table.public.id
}

resource "aws_security_group" "app_server" {
  name        = "app-server-sg"
  description = "Security group for app server"
  vpc_id      = aws_vpc.main.id

  ingress {
    description = "SSH from anywhere"
    from_port   = 22
    to_port     = 22
    protocol    = "tcp"
    cidr_blocks = ["0.0.0.0/0"]
  }

  ingress {
    description = "HTTP from anywhere"
    from_port   = 80
    to_port     = 80
    protocol    = "tcp"
    cidr_blocks = ["0.0.0.0/0"]
  }

  egress {
    from_port   = 0
    to_port     = 0
    protocol    = "-1"
    cidr_blocks = ["0.0.0.0/0"]
  }

  tags = {
    Name = "app-server-sg"
  }
}

resource "aws_instance" "app_server" {
  ami           = "ami-830c94e3"
  instance_type = "t2.micro"
  subnet_id     = aws_subnet.public.id

  vpc_security_group_ids = [aws_security_group.app_server.id]

  tags = {
    Name = "AppServer"
  }
}

variable "environment" {
  description = "Environment name"
  type        = string
  default     = "development"
}

output "instance_public_ip" {
  description = "Public IP of the app server"
  value       = aws_instance.app_server.public_ip
}

output "vpc_id" {
  description = "ID of the VPC"
  value       = aws_vpc.main.id
}
```

{% endcode %}

## Visualization in iCraft

<figure><img src="/files/z8bnncEzBfq5GwfmzfKd" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.icraft.design/editor-features/navigation-bar/labs/terraform-visualization.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
