Skip to main content
phala_app is the primary lifecycle resource in the Phala Cloud Terraform provider. It manages a single application identity (app_id) with shared Docker Compose configuration, shared environment variables, and one or more CVM replicas. This is the resource you use for every deployment.

Example Usage

Required Attributes

Optional Attributes

Placement and Identity

Infrastructure

Compose Runtime Settings

These attributes control compose-level runtime behavior. Changing any of them triggers a compose update and CVM restart.

Environment Variables

The provider offers two modes for managing environment variables. You must pick one — they cannot be combined in the same resource. Auto-encryption mode (recommended):
Even in auto-encryption mode, plaintext values are stored in your Terraform state file. If you cannot tolerate plaintext in state storage, use manual encrypted mode instead.
Manual encrypted mode:
On-chain KMS fields (advanced):

Wait Behavior

Setting wait_for_ready = true is recommended for production workflows. Without it, Terraform returns immediately after the API call, and subsequent resources that depend on the endpoint may see incomplete values.

Read-Only (Computed) Attributes

Lifecycle Behavior

Force-New Fields

Changing any of these attributes destroys the existing resource and creates a new one:
  • name
  • region
  • listed
  • ssh_authorized_keys
  • storage_fs
  • kms
  • custom_app_id
  • nonce
  • node_id

In-Place Updates

These attributes can be updated without replacement:
  • size (CPU/RAM changes)
  • disk_size (grow only)
  • image (OS image swap via API patch)
  • docker_compose
  • pre_launch_script
  • replicas
  • env / encrypted_env
  • Compose runtime settings (public_logs, public_sysinfo, public_tcbinfo, gateway_enabled, secure_time)

Replica Scaling

Set replicas to scale your app horizontally. All replicas share the same compose file, environment, and settings. The provider manages replica creation and deletion to match your desired count.

Create Flow

The provider follows Phala’s two-step API: first POST /cvms/provision to allocate resources, then POST /cvms to commit the deployment. This happens automatically during terraform apply.