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):
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:nameregionlistedssh_authorized_keysstorage_fskmscustom_app_idnoncenode_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_composepre_launch_scriptreplicasenv/encrypted_env- Compose runtime settings (
public_logs,public_sysinfo,public_tcbinfo,gateway_enabled,secure_time)
Replica Scaling
Setreplicas 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: firstPOST /cvms/provision to allocate resources, then POST /cvms to commit the deployment. This happens automatically during terraform apply.

