> 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). Agents can also search and read this documentation through its [MCP server](https://docs.icraft.design/~gitbook/mcp).

# 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="https://2043086618-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fqs5xBLyTN4cVMplr2ANM%2Fuploads%2Fv8UiifA6lZYXWBW6gXn9%2Fimage.png?alt=media&amp;token=531e45e0-c701-4b73-abb1-cfae8476c08a" alt=""><figcaption></figcaption></figure>
