Terraform and VCD 10.6: How to Manage Infrastructure as Code

Terraform and VCD 10.6: How to Manage Infrastructure as Code

Modules, Examples, and Best Practices for Automating Cloud Director Services

With VMware Cloud Director (VCD) 10.6, support for Terraform has become more powerful, allowing cloud providers and tenants to manage cloud resources using Infrastructure as Code (IaC). This shift from manual provisioning to declarative code enables faster deployments, improved consistency, and seamless automation.

In this article, we explore how to use Terraform to provision and manage VCD services, including real module examples and code snippets you can try today.


Why Use Terraform with VCD?

Using Terraform with VCD offers several advantages:

  • Consistency: Define your infrastructure once, deploy repeatedly across tenants
  • Version Control: Keep infrastructure configurations in Git
  • Automation: Integrate with CI/CD pipelines for on-demand deployments
  • Scalability: Manage multiple tenants and environments efficiently

Key Capabilities of Terraform Provider for VCD 10.6

  • Create and manage Organizations
  • Provision Org VDCs (Virtual Data Centers)
  • Configure vApps, VMs, and Networks
  • Deploy NSX-T Edge Gateways, Firewall Rules, and NAT
  • Apply Storage and Compute Policies

Terraform vCD provider now supports both NSX-T and NSX-V, with NSX-T being the modern default.


Example: Provisioning an Org VDC

hCopyEditprovider "vcd" {
  user                 = "admin@system"
  password             = "SuperSecurePassword"
  org                  = "System"
  url                  = "https://vcloud.example.com/api"
  allow_unverified_ssl = true
}

resource "vcd_org" "demo_org" {
  name        = "demo-org"
  full_name   = "Demo Organization"
  is_enabled  = true
}

resource "vcd_org_vdc" "demo_vdc" {
  name           = "demo-vdc"
  org            = vcd_org.demo_org.name
  allocation_model = "AllocationVApp"
  provider_vdc   = "pvdc-1"
  network_pool_name = "vxlan-pool"
  storage_profile = "gold"
  cpu_guaranteed = 1
  memory_guaranteed = 1
}

✅ This script:

  • Creates a new organization called demo-org
  • Deploys a VDC with specified compute/storage settings

Reusability with Terraform Modules

You can create reusable modules for common VCD objects like:

  • org-vdc-network
  • edge-gateway
  • firewall-rules
  • vm-templates

Example module usage:

hclCopyEditmodule "edge-gateway" {
  source      = "./modules/nsxt-edge"
  name        = "demo-edge"
  org         = "demo-org"
  vdc         = "demo-vdc"
  external_network = "internet"
}

Join the discussion

Bülleten