Docs
Skip to content

Terraform provider

Sites_

Manage Appwrite Sites, environment variables, and deployments with Terraform.

2 min read

Raw

Sites supports Terraform resources for the site definition, build-time environment variables, and deployments that publish your site from a local artifact or a Git template.

See the Terraform Registry: site, site_variable, and site_deployment. The provider repository includes examples.

Resources

ResourcePurpose
appwrite_siteCreate and update a site (framework, build and install commands, runtimes, and related settings)
appwrite_site_variableSet environment variables for a site (for example NEXT_PUBLIC_* keys)
appwrite_site_deploymentPush a new deployment from local code (tar.gz) or a Git template and optionally activate it

Examples

The framework argument accepts nextjs, nuxt, sveltekit, astro, remix, analog, react, vue, vite, flutter, and other. Use other for static sites or unsupported frameworks.

Static site

Terraform
resource "appwrite_site" "landing_page" {
name = "landing-page"
framework = "other"
build_runtime = "node-22"
}

Next.js site

Terraform
resource "appwrite_site" "dashboard" {
name = "dashboard"
framework = "nextjs"
build_runtime = "node-22"
install_command = "npm install"
build_command = "npm run build"
}

Astro site

Astro and other static-output frameworks need an explicit output_directory pointing at the build artifact.

Terraform
resource "appwrite_site" "docs" {
name = "docs"
framework = "astro"
build_runtime = "node-22"
install_command = "npm install"
build_command = "npm run build"
output_directory = "dist"
}

Environment variables

appwrite_site_variable attaches build-time environment variables (for example NEXT_PUBLIC_* keys). Mark sensitive values with secret = true so the value is not readable from the API after creation.

Terraform
resource "appwrite_site_variable" "api_url" {
site_id = appwrite_site.dashboard.id
key = "NEXT_PUBLIC_API_URL"
value = "https://api.example.com"
}
resource "appwrite_site_variable" "secret_key" {
site_id = appwrite_site.dashboard.id
key = "SECRET_KEY"
value = var.secret_key
secret = true
}

VCS integration

Connect a site to a Git repository so Appwrite deploys automatically on push. Obtain the installation_id and provider_repository_id from your Appwrite GitHub (or other VCS) integration.

Terraform
resource "appwrite_site" "app" {
name = "app"
framework = "nextjs"
build_runtime = "node-22"
installation_id = "your-github-installation-id"
provider_repository_id = "your-repository-id"
provider_branch = "main"
provider_root_directory = "apps/web"
}

Deploy from local code

Use source_type = "code" to upload a tar.gz build artifact. code_hash lets Terraform detect changes to the artifact and trigger a fresh deployment on the next apply.

Terraform
resource "appwrite_site_deployment" "dashboard" {
site_id = appwrite_site.dashboard.id
source_type = "code"
code_path = "dist/dashboard.tar.gz"
code_hash = filesha256("dist/dashboard.tar.gz")
install_command = "npm install"
build_command = "npm run build"
output_directory = ".next"
activate = true
}

Deploy from a template repository

Use source_type = "template" to deploy from a Git repository (for example one of Appwrite's site templates). Pin type to branch, tag, or commit and set reference accordingly.

Terraform
resource "appwrite_site_deployment" "from_template" {
site_id = appwrite_site.dashboard.id
source_type = "template"
repository = "templates-for-sites"
owner = "appwrite"
root_directory = "nextjs/starter"
type = "branch"
reference = "main"
activate = true
}

By default the resource waits for the build to finish before it returns; set wait_for_ready = false if you want terraform apply to return as soon as the deployment is queued.

Data sources

The appwrite_site data source reads an existing site by ID. Use it when the site was created outside Terraform or in another state, and you need to reference attributes such as framework or the active deployment_id.

Terraform
data "appwrite_site" "existing" {
id = "dashboard"
}
output "site_framework" {
value = data.appwrite_site.existing.framework
}

See the Terraform Registry for the full attribute list.

Was this page helpful?

Share what worked or what we should fix. Once approved, our agents automatically apply suggested updates to the docs.