Skip to main content
The Terraform Provider is currently in beta. The resource schema may change between releases.
The Phala Cloud Terraform provider lets you manage confidential virtual machines (CVMs) using standard Terraform workflows. It follows an app-first model where phala_app is the primary resource, managing one application identity with shared Docker Compose configuration, shared environment variables, and one or more CVM replicas. If you have used providers like DigitalOcean or AWS, the patterns here will feel familiar: catalog data sources for discovery, declarative compute resources, explicit power control, and SSH key management.

Installation

The provider is published on the Terraform Registry under phala-network/phala. Add it to your required_providers block:
Run terraform init to download the provider binary. Terraform handles the rest automatically.

Authentication

The provider authenticates with a Phala Cloud API key. You can get one from the dashboard:
  1. Sign in at cloud.phala.com.
  2. Go to Settings then API Keys.
  3. Create a key and export it in your shell:
The provider reads PHALA_CLOUD_API_KEY automatically. You can also set it explicitly in the provider block, though environment variables are recommended for security.

Provider Configuration

Quick Start

This deploys a single nginx CVM and outputs the app ID and public endpoint. The values below (tdx.medium, US-WEST-1, 40 GB disk) are tested defaults that work out of the box.
Run the standard Terraform workflow:
When it completes, Terraform prints the app_id and a public endpoint URL. Your app also appears in the Phala Cloud dashboard in a running state. To tear down:

What’s in the Provider

The provider includes three resources and seven data sources: Resources:
  • phala_app — the primary lifecycle resource for deploying apps with CVM replicas
  • phala_cvm_power — start/stop power control for existing CVMs
  • phala_ssh_key — manage account-level SSH keys
Data Sources:

Common Workflow

A typical deployment follows this pattern:
  1. Use data sources (phala_sizes, phala_regions, phala_images) to discover valid slugs.
  2. Define a phala_app with your Docker Compose file and desired replica count.
  3. Wait for readiness, then consume app_id, cvm_ids, and endpoint as outputs.
  4. Optionally use phala_cvm_power for explicit start/stop control after deployment.