Architect

Terraform Generation & Deployment

AIVory Architect generates production-ready Terraform code from your visual designs and can deploy infrastructure directly from your IDE.

  • Production-ready code generated from visual designs
  • Dependency resolution automatically orders resources correctly
  • Diff viewer shows changes before overwriting files
  • One-click deployment directly from your IDE (Premium)
  • State tracking shows deployed status on canvas

Code Generation

Generated Files

When you click Generate Terraform, Architect creates:

File Contents
main.tf All resource definitions
variables.tf Input variables for configuration
outputs.tf Output values (IPs, endpoints, etc.)
providers.tf Provider configuration blocks
terraform.tfvars.example Example variable values

Files are saved to .aivory/terraform/ by default.

Generation Process

Resource Collection
All canvas resources are collected
Dependency Resolution
Connections are analyzed for ordering
Topological Sort
Resources are ordered by dependencies
Template Rendering
Provider-specific templates generate HCL
Variable Extraction
Secrets and config become variables
Output Generation
Resource attributes become outputs

Diff Viewer

Before overwriting existing files, Architect shows a diff view:

  • Green lines: New additions
  • Red lines: Removed content
  • Yellow lines: Modified content
Note Review changes before confirming to prevent accidental overwrites.

Generated Code Example

Visual Design

N e t w o r k ( S 1 e 0 r . v 0 e V . r o 0 l . ( u 0 c m / x e 8 2 ) 1 ( , 5 0 U G b B u ) n t u 2 2 . 0 4 )

Generated Terraform

View full generated code example
# providers.tf
terraform {
  required_providers {
    hcloud = {
      source  = "hetznercloud/hcloud"
      version = "~> 1.45"
    }
  }
}

provider "hcloud" {
  token = var.hcloud_token
}

# variables.tf
variable "hcloud_token" {
  description = "Hetzner Cloud API token"
  type        = string
  sensitive   = true
}

variable "server_type" {
  description = "Server type for web server"
  type        = string
  default     = "cx21"
}

# main.tf
resource "hcloud_network" "main" {
  name     = "main-network"
  ip_range = "10.0.0.0/8"
}

resource "hcloud_network_subnet" "main" {
  network_id   = hcloud_network.main.id
  type         = "cloud"
  network_zone = "eu-central"
  ip_range     = "10.0.1.0/24"
}

resource "hcloud_server" "web" {
  name        = "web-server"
  server_type = var.server_type
  image       = "ubuntu-22.04"
  location    = "nbg1"

  network {
    network_id = hcloud_network.main.id
    ip         = "10.0.1.2"
  }

  depends_on = [hcloud_network_subnet.main]
}

resource "hcloud_volume" "data" {
  name     = "data-volume"
  size     = 50
  location = "nbg1"
}

resource "hcloud_volume_attachment" "data" {
  volume_id = hcloud_volume.data.id
  server_id = hcloud_server.web.id
  automount = true
}

# outputs.tf
output "server_ip" {
  description = "Public IP of the web server"
  value       = hcloud_server.web.ipv4_address
}

output "server_private_ip" {
  description = "Private IP of the web server"
  value       = hcloud_server.web.network[*].ip
}

Deployment (Premium)

Success Direct deployment from your IDE requires a premium subscription.

Deployment Workflow

1. Click Deploy
Opens the deployment panel
2. Terraform Init
Automatically initializes providers
3. Terraform Plan
Shows what will be created/modified/destroyed
4. Review
Examine the plan for unexpected changes
5. Confirm
Click to run terraform apply
6. Monitor
Watch real-time progress and logs

Deployment Panel

The deployment panel shows:

  • Status: Current operation (init/plan/apply)
  • Progress: Visual progress indicator
  • Logs: Streaming Terraform output
  • Resources: List of resources being managed
  • Outputs: Values from outputs.tf after apply

Cancel Operations

Long-running operations can be cancelled:

  1. Click Cancel in the deployment panel
  2. Terraform gracefully stops
  3. Partial changes may remain - check state
Warning Cancelling during apply may leave resources in an inconsistent state. Always verify with terraform plan after cancellation.

State Management

State File

Terraform tracks deployed resources in terraform.tfstate:

  • Architect reads this file to show deployed status
  • Never edit the state file manually
  • Back up state files before major changes
Note For team collaboration, use a remote backend (S3, Azure Blob, etc.) instead of local state files.

Deployed Resource Tracking

After deployment, the canvas shows:

Green Indicator
Resource deployed successfully
Yellow Indicator
Resource has drift (manual changes detected)
Red Indicator
Resource failed to deploy

Refresh State

Click Refresh to update the canvas from current state:

  1. Reads terraform.tfstate
  2. Updates resource status indicators
  3. Detects any drift from design

Advanced Configuration

Custom Backend

Add backend configuration for remote state:

# backend.tf (create manually)
terraform {
  backend "s3" {
    bucket = "my-terraform-state"
    key    = "project/terraform.tfstate"
    region = "us-east-1"
  }
}
Variable Files

Create terraform.tfvars for environment-specific values:

hcloud_token = "your-token-here"
server_type  = "cx31"

Or use separate files per environment:

terraform apply -var-file="production.tfvars"
Workspaces

Terraform workspaces let you manage multiple environments:

terraform workspace new staging
terraform workspace select staging
terraform apply

Troubleshooting

Provider not found
Run terraform init manually or click Initialize in Architect.
Resource already exists

The resource exists but isn’t in state. Either:

  • Import it: terraform import resource_type.name id
  • Delete it manually and re-apply
Cycle detected
Circular dependency in your design. Review connections and break the cycle.
Permission denied
Check your cloud provider credentials in .env or credential vault.

Best Practices

Version Control
Commit .tf files to git. Don’t commit state or credentials.
Code Review
Review generated code before deploying. Use terraform plan to preview.
Modular Design
Group related resources. Use consistent naming conventions.
Test First
Test in a staging environment before deploying to production.
Note Consider splitting large designs into modules for better maintainability and reusability.

Next Steps