diff --git a/src/routes/blog/post/introducing-terraform-provider-for-appwrite/+page.markdoc b/src/routes/blog/post/introducing-terraform-provider-for-appwrite/+page.markdoc index ca23b0b943..db128e585e 100644 --- a/src/routes/blog/post/introducing-terraform-provider-for-appwrite/+page.markdoc +++ b/src/routes/blog/post/introducing-terraform-provider-for-appwrite/+page.markdoc @@ -1,7 +1,7 @@ --- layout: post title: "Introducing Terraform support for Appwrite projects" -description: "The official appwrite/appwrite Terraform provider brings Appwrite project resources into HashiCorp Configuration Language (HCL): databases through messaging, with Registry docs, imports, and first-party guides for Cloud and self-hosted Community Edition." +description: "The official appwrite/appwrite Terraform provider brings your entire Appwrite project into HashiCorp Configuration Language (HCL): TablesDB, Storage, Functions, Sites, Auth, Messaging, Webhooks, and Backup Policies - with Registry docs, imports, and guides for Cloud and self-hosted Community Edition." date: 2026-04-08 cover: /images/blog/terraform-provider-appwrite/cover.svg timeToRead: 10 @@ -10,13 +10,13 @@ category: product, announcement featured: false --- -If you already treat infrastructure as code elsewhere, Appwrite **project configuration** was the odd layer out: databases, tables, storage buckets, and messaging providers were easy to tweak in the Console, with the CLI, or in `appwrite.json`, and hard to keep identical across staging, production, and extra regions. That is operational drift with a familiar fix - declare the same resources in HashiCorp Configuration Language (HCL), store the Terraform **state** next to your other tooling, and let `plan` / `apply` (or your CI wrapper) do the talking. +If you already treat infrastructure as code elsewhere, Appwrite **project configuration** was the odd layer out: databases, tables, storage buckets, functions, and sites were easy to tweak in the Console, with the CLI, or in `appwrite.json`, and hard to keep identical across staging, production, and extra regions. That is operational drift with a familiar fix - declare the same resources in HashiCorp Configuration Language (HCL), store the Terraform **state** next to your other tooling, and let `plan` / `apply` (or your CI wrapper) do the talking. -The **official Terraform provider** is now published as [`appwrite/appwrite`](https://registry.terraform.io/providers/appwrite/appwrite/latest) on the HashiCorp Terraform Registry. It manages **project** resources over the Appwrite API (databases, tables, buckets, messaging, and related objects). It does **not** install or operate the Appwrite **instance** itself - for that, stay with [self-hosting](/docs/advanced/self-hosting) and your existing deployment story. +The **official Terraform provider** is now published as [`appwrite/appwrite`](https://registry.terraform.io/providers/appwrite/appwrite/latest) on the HashiCorp Terraform Registry. It manages **project** resources over the Appwrite API - TablesDB, Storage, Functions, Sites, Auth, Messaging, Webhooks, and Backup Policies. It does **not** install or operate the Appwrite **instance** itself - for that, stay with [self-hosting](/docs/advanced/self-hosting) and your existing deployment story. # Why we built it this way -We set out to make Terraform **cross-cutting** across Appwrite **project** configuration - not a databases-only path you abandon when you work on Storage, Messaging, or the next surface area. The provider targets **most** of what you manage at the project layer through the API (Tables, Storage, and Messaging today, with more to follow), so one IaC story covers those capabilities instead of a tool that stops at schemas. +We set out to make Terraform **cross-cutting** across Appwrite **project** configuration - not a databases-only path you abandon when you work on Functions, Sites, or the next surface area. The provider targets **most** of what you manage at the project layer through the API, so one IaC story covers those capabilities instead of a tool that stops at schemas. **Cross-project** mattered too: the same workflow is meant to work **across** Appwrite projects and environments when you need aligned baselines, not only inside a single stack or a single product silo. @@ -24,51 +24,89 @@ We also wanted it **open by design**. Use it for familiar patterns - parity betw # What is in scope -The provider maps Appwrite project resources to Terraform resources you would expect if you have already read the Tables, Storage, and Messaging docs: for example `appwrite_database`, `appwrite_table`, `appwrite_column`, and `appwrite_index` for **Tables** workloads; `appwrite_bucket` for **Storage**; `appwrite_messaging_provider` and `appwrite_messaging_topic` for **Messaging**. An **`appwrite_database` data source** lets you look up an existing database by ID when another resource needs a stable reference. +The provider maps Appwrite project resources to Terraform resources the way you would expect if you have used the platform before. **TablesDB** is the deepest surface: databases, tables, columns, indexes, and even rows so you can declare schemas and seed data in HCL. **Storage** covers buckets and file uploads. **Functions** and **Sites** let you define serverless functions (with runtimes, schedules, event triggers, and environment variables) and hosted frontends (with framework presets for Next.js, Nuxt, Astro, SvelteKit, and others) right alongside the backend resources they depend on. **Auth** resources manage users and teams, **Messaging** handles providers, topics, and subscribers, and dedicated resources for **Webhooks** and **Backup Policies** round out the set. -Authentication is the same model as any other automation: your Appwrite **API endpoint**, a **project API key** with the right scopes, and (on Community Edition or dev clusters) whatever TLS settings you already use - the [configuration guide](/docs/tooling/terraform/provider) documents `endpoint`, `project_id`, `api_key`, and `self_signed` so you can mirror how CI talks to Appwrite today. +Authentication follows the same model as any other automation: your Appwrite **API endpoint**, a **project API key** with the right scopes, and (on Community Edition or dev clusters) whatever TLS settings you already use - the [configuration guide](/docs/tooling/terraform/provider) documents `endpoint`, `project_id`, `api_key`, and `self_signed` so you can mirror how CI talks to Appwrite today. # What a basic flow looks like End to end, Terraform does what you expect: pin the provider, pass credentials, declare resources, then run `terraform init`, `terraform plan`, and `terraform apply` when you like the diff. The snippets below are intentionally small so you can see the shape before you open the full guides. -**Provider and Cloud endpoint.** Declare `appwrite/appwrite`, then point the provider at Appwrite Cloud (swap `` for your [region](/docs/products/network/regions) subdomain). On Community Edition, set `endpoint` to your instance URL and use `self_signed` when you need it - the [Configuration](/docs/tooling/terraform/provider) page has the exact pattern. +**Provider and Configuration.** Declare `appwrite/appwrite`, then point the provider at Appwrite Cloud (swap `` for your [region](/docs/products/network/regions) subdomain). On Community Edition, set `endpoint` to your instance URL and use `self_signed` when you need it - the [Configuration](/docs/tooling/terraform/provider) page has the exact pattern. ```hcl terraform { required_providers { appwrite = { - source = "appwrite/appwrite" + source = "appwrite/appwrite" + version = "1.0.1" } } } provider "appwrite" { endpoint = "https://.cloud.appwrite.io/v1" - project_id = "your-project-id" - api_key = "your-api-key" + project_id = "project-id" + api_key = "api-key" } ``` -**One database.** A single `appwrite_database` resource is enough to prove the loop: Terraform creates the database in your project on apply. +**A database and table.** A single `appwrite_tablesdb` resource creates a database, and `appwrite_tablesdb_table` adds a table inside it. ```hcl -resource "appwrite_database" "main" { - id = "main_db" - name = "Main database" +resource "appwrite_tablesdb" "main" { + name = "main" +} + +resource "appwrite_tablesdb_table" "users" { + database_id = appwrite_tablesdb.main.id + name = "users" +} +``` + +**A storage bucket.** Buckets follow the same pattern - declare the resource, configure it with the options you need. + +```hcl +resource "appwrite_storage_bucket" "images" { + name = "images" + maximum_file_size = 10485760 + allowed_file_extensions = ["jpg", "png", "webp", "gif"] + compression = "gzip" +} +``` + +**A serverless function.** Declare the runtime, wire up event triggers, and set environment variables - all in HCL. + +```hcl +resource "appwrite_function" "on_signup" { + name = "on-signup" + runtime = "node-22" + entrypoint = "index.js" + commands = "npm install" + events = ["users.*.create"] + timeout = 30 +} + +resource "appwrite_function_variable" "api_url" { + function_id = appwrite_function.on_signup.id + key = "API_URL" + value = "https://api.example.com" } ``` -**One storage bucket.** Buckets follow the same idea - another resource type, same provider block, no extra ceremony. +**A hosted site.** Pick a framework preset and configure the build pipeline. ```hcl -resource "appwrite_bucket" "uploads" { - id = "user_uploads" - name = "User uploads" +resource "appwrite_site" "dashboard" { + name = "dashboard" + framework = "nextjs" + build_runtime = "node-22" + install_command = "npm install" + build_command = "npm run build" } ``` -From there you layer tables, columns, indexes, messaging resources, and data sources as needed - the [Databases](/docs/tooling/terraform/resources/databases), [Storage](/docs/tooling/terraform/resources/storage), and [Messaging](/docs/tooling/terraform/resources/messaging) guides walk through IDs and dependencies. +From there you layer columns, indexes, messaging resources, webhooks, backup policies, and data sources as needed - the [Databases](/docs/tooling/terraform/resources/databases), [Storage](/docs/tooling/terraform/resources/storage), and [Messaging](/docs/tooling/terraform/resources/messaging) guides walk through IDs and dependencies. # How Terraform fits diff --git a/src/routes/docs/tooling/terraform/+layout.svelte b/src/routes/docs/tooling/terraform/+layout.svelte index 5bf6322d45..52f7460944 100644 --- a/src/routes/docs/tooling/terraform/+layout.svelte +++ b/src/routes/docs/tooling/terraform/+layout.svelte @@ -32,9 +32,29 @@ label: 'Storage', href: '/docs/tooling/terraform/resources/storage' }, + { + label: 'Functions', + href: '/docs/tooling/terraform/resources/functions' + }, + { + label: 'Sites', + href: '/docs/tooling/terraform/resources/sites' + }, + { + label: 'Auth', + href: '/docs/tooling/terraform/resources/auth' + }, { label: 'Messaging', href: '/docs/tooling/terraform/resources/messaging' + }, + { + label: 'Webhooks', + href: '/docs/tooling/terraform/resources/webhooks' + }, + { + label: 'Backup policies', + href: '/docs/tooling/terraform/resources/backup-policies' } ] }, diff --git a/src/routes/docs/tooling/terraform/+page.markdoc b/src/routes/docs/tooling/terraform/+page.markdoc index 91391fef95..4fd6ca5472 100644 --- a/src/routes/docs/tooling/terraform/+page.markdoc +++ b/src/routes/docs/tooling/terraform/+page.markdoc @@ -4,20 +4,31 @@ title: Terraform provider description: Manage Appwrite infrastructure as code with the official Terraform provider. Works with Appwrite Cloud and Community Edition. --- -The [Terraform provider for Appwrite](https://github.com/appwrite/terraform-provider-appwrite) lets you declare **Tables** resources (databases, tables, columns, indexes), **Storage** buckets, **Messaging** providers and topics, and more in `.tf` files, and apply those changes through [HashiCorp Terraform](https://www.terraform.io/). It is the official way to automate Appwrite project configuration alongside the rest of your stack. +The [Terraform provider for Appwrite](https://github.com/appwrite/terraform-provider-appwrite) lets you declare project resources - databases, tables, storage buckets, functions, sites, auth, messaging, webhooks, and backup policies - in `.tf` files and apply those changes through [HashiCorp Terraform](https://www.terraform.io/). It is the official way to automate Appwrite project configuration alongside the rest of your stack. # Resources and data sources {% #resources-and-data-sources %} | Kind | Name | Description | |------|------|-------------| -| Resource | `appwrite_database` | Database | -| Resource | `appwrite_table` | Table within a database | -| Resource | `appwrite_column` | Column on a table | -| Resource | `appwrite_index` | Index on a table | -| Resource | `appwrite_bucket` | Storage bucket | -| Resource | `appwrite_messaging_provider` | Messaging provider (email, SMS, push, etc.) | +| Resource | `appwrite_tablesdb` | Database | +| Resource | `appwrite_tablesdb_table` | Table within a database | +| Resource | `appwrite_tablesdb_column` | Column on a table | +| Resource | `appwrite_tablesdb_index` | Index on a table | +| Resource | `appwrite_tablesdb_row` | Row in a table | +| Resource | `appwrite_storage_bucket` | Storage bucket | +| Resource | `appwrite_storage_file` | File in a bucket | +| Resource | `appwrite_function` | Serverless function | +| Resource | `appwrite_function_variable` | Function environment variable | +| Resource | `appwrite_site` | Hosted site | +| Resource | `appwrite_site_variable` | Site environment variable | +| Resource | `appwrite_auth_user` | User | +| Resource | `appwrite_auth_team` | Team | +| Resource | `appwrite_messaging_provider` | Messaging provider (email, SMS, push) | | Resource | `appwrite_messaging_topic` | Messaging topic | -| Data source | `appwrite_database` | Look up a database by ID | +| Resource | `appwrite_messaging_subscriber` | Messaging subscriber | +| Resource | `appwrite_webhook` | Webhook | +| Resource | `appwrite_backup_policy` | Backup policy | +| Data source | `appwrite_tablesdb` | Look up a database by ID | {% info title="Looking for self-hosting?" %} This section is about **Appwrite resources inside a project** (for example databases and tables) using Terraform. If you want to install or operate the Appwrite server itself (Docker, configuration, TLS, scaling), go to the [self-hosting documentation](/docs/advanced/self-hosting) instead. @@ -58,13 +69,28 @@ The provider works with **Appwrite Cloud** and **Community Edition** (self-hoste Install the provider, set endpoints, and use environment variables for credentials. {% /cards_item %} {% cards_item href="/docs/tooling/terraform/resources/databases" title="Databases" %} -Manage databases, tables, columns, and indexes. +Manage databases, tables, columns, indexes, and rows. {% /cards_item %} {% cards_item href="/docs/tooling/terraform/resources/storage" title="Storage" %} -Configure storage buckets and file policies. +Configure storage buckets and managed file uploads. +{% /cards_item %} +{% cards_item href="/docs/tooling/terraform/resources/functions" title="Functions" %} +Deploy serverless functions with runtimes, schedules, and event triggers. +{% /cards_item %} +{% cards_item href="/docs/tooling/terraform/resources/sites" title="Sites" %} +Host frontends with framework presets and build configuration. +{% /cards_item %} +{% cards_item href="/docs/tooling/terraform/resources/auth" title="Auth" %} +Manage users and teams. {% /cards_item %} {% cards_item href="/docs/tooling/terraform/resources/messaging" title="Messaging" %} -Define messaging providers and topics. +Define messaging providers, topics, and subscribers. +{% /cards_item %} +{% cards_item href="/docs/tooling/terraform/resources/webhooks" title="Webhooks" %} +Configure event-driven HTTP callbacks. +{% /cards_item %} +{% cards_item href="/docs/tooling/terraform/resources/backup-policies" title="Backup policies" %} +Schedule backups with retention policies. {% /cards_item %} {% cards_item href="/docs/tooling/terraform/data-sources" title="Data sources" %} Look up existing databases by ID for use in other resources. diff --git a/src/routes/docs/tooling/terraform/data-sources/+page.markdoc b/src/routes/docs/tooling/terraform/data-sources/+page.markdoc index 81ee7bbe77..1da8377521 100644 --- a/src/routes/docs/tooling/terraform/data-sources/+page.markdoc +++ b/src/routes/docs/tooling/terraform/data-sources/+page.markdoc @@ -6,22 +6,21 @@ description: Use Terraform data sources to read existing Appwrite databases by I **Data sources** let Terraform read resources that already exist instead of creating them. The Appwrite provider currently exposes a data source for **databases** so you can reference an existing database by ID in your configuration. -See the [Terraform Registry reference](https://registry.terraform.io/providers/appwrite/appwrite/latest/docs/data-sources/database) for the full argument list, and the [provider repository](https://github.com/appwrite/terraform-provider-appwrite) for source and changes. +See the [Terraform Registry reference](https://registry.terraform.io/providers/appwrite/appwrite/latest/docs/data-sources/tablesdb) for the full argument list, and the [provider repository](https://github.com/appwrite/terraform-provider-appwrite) for source and changes. -# `appwrite_database` {% #appwrite-database %} +# `appwrite_tablesdb` {% #appwrite-tablesdb %} Use this when a database was created outside Terraform (or in another state) and you need its identity in your module. ```hcl -data "appwrite_database" "existing" { +data "appwrite_tablesdb" "existing" { id = "main" } # Example: reference in another resource -resource "appwrite_table" "example" { - database_id = data.appwrite_database.existing.id - id = "example" - name = "Example" +resource "appwrite_tablesdb_table" "example" { + database_id = data.appwrite_tablesdb.existing.id + name = "example" } ``` diff --git a/src/routes/docs/tooling/terraform/provider/+page.markdoc b/src/routes/docs/tooling/terraform/provider/+page.markdoc index 80118c22ac..7f86081148 100644 --- a/src/routes/docs/tooling/terraform/provider/+page.markdoc +++ b/src/routes/docs/tooling/terraform/provider/+page.markdoc @@ -70,7 +70,12 @@ Use a key with the scopes required for the resources you manage (for example dat # Related {% #related %} -- [Databases](/docs/tooling/terraform/resources/databases) - Tables resources -- [Storage](/docs/tooling/terraform/resources/storage) - buckets -- [Messaging](/docs/tooling/terraform/resources/messaging) - providers and topics +- [Databases](/docs/tooling/terraform/resources/databases) - databases, tables, columns, indexes, and rows +- [Storage](/docs/tooling/terraform/resources/storage) - buckets and file uploads +- [Functions](/docs/tooling/terraform/resources/functions) - serverless functions and environment variables +- [Sites](/docs/tooling/terraform/resources/sites) - hosted frontends and environment variables +- [Auth](/docs/tooling/terraform/resources/auth) - users and teams +- [Messaging](/docs/tooling/terraform/resources/messaging) - providers, topics, and subscribers +- [Webhooks](/docs/tooling/terraform/resources/webhooks) - event-driven HTTP callbacks +- [Backup policies](/docs/tooling/terraform/resources/backup-policies) - scheduled backups - [Self-hosting](/docs/advanced/self-hosting) - install and run the Appwrite server (not the same as configuring project resources with this provider) diff --git a/src/routes/docs/tooling/terraform/resources/auth/+page.markdoc b/src/routes/docs/tooling/terraform/resources/auth/+page.markdoc new file mode 100644 index 0000000000..a31b068915 --- /dev/null +++ b/src/routes/docs/tooling/terraform/resources/auth/+page.markdoc @@ -0,0 +1,53 @@ +--- +layout: article +title: Auth +description: Manage Appwrite users and teams with the Terraform provider for repeatable auth setup across environments. +--- + +The `appwrite_auth_user` and `appwrite_auth_team` resources manage [Auth](/docs/products/auth) objects in your Appwrite project: seed users for development or testing, and teams with custom roles. + +See the Terraform Registry for the full attribute list and import syntax: [auth_user](https://registry.terraform.io/providers/appwrite/appwrite/latest/docs/resources/auth_user) and [auth_team](https://registry.terraform.io/providers/appwrite/appwrite/latest/docs/resources/auth_team). The [provider repository](https://github.com/appwrite/terraform-provider-appwrite) has source and examples. + +# Resources {% #resources %} + +| Resource | Purpose | +|----------|---------| +| `appwrite_auth_user` | Create a user | +| `appwrite_auth_team` | Create a team with optional roles | + +# Examples {% #examples %} + +## Users {% #users %} + +```hcl +resource "appwrite_auth_user" "john" { + name = "john doe" + email = "john@example.com" + password = var.user_password +} + +resource "appwrite_auth_user" "admin" { + name = "admin" + email = "admin@example.com" + password = var.admin_password + labels = ["admin", "staff"] +} +``` + +## Teams {% #teams %} + +```hcl +resource "appwrite_auth_team" "engineering" { + name = "engineering" +} + +resource "appwrite_auth_team" "marketing" { + name = "marketing" + roles = ["owner", "editor"] +} +``` + +# Related {% #related %} + +- [Auth product docs](/docs/products/auth) +- [Configuration](/docs/tooling/terraform/provider) diff --git a/src/routes/docs/tooling/terraform/resources/backup-policies/+page.markdoc b/src/routes/docs/tooling/terraform/resources/backup-policies/+page.markdoc new file mode 100644 index 0000000000..dfc13ea794 --- /dev/null +++ b/src/routes/docs/tooling/terraform/resources/backup-policies/+page.markdoc @@ -0,0 +1,49 @@ +--- +layout: article +title: Backup policies +description: Schedule Appwrite backups with retention policies using the Terraform provider. +--- + +The `appwrite_backup_policy` resource manages backup policies in your Appwrite project: target services, cron schedules, retention periods, and optional scoping to a specific resource. + +See the [backup_policy resource](https://registry.terraform.io/providers/appwrite/appwrite/latest/docs/resources/backup_policy) on the Terraform Registry for the full attribute list and import syntax. The [provider repository](https://github.com/appwrite/terraform-provider-appwrite) has source and examples. + +# Resource {% #resource %} + +| Resource | Purpose | +|----------|---------| +| `appwrite_backup_policy` | Schedule backups with a retention window | + +# Examples {% #examples %} + +## Daily backup {% #daily-backup %} + +```hcl +resource "appwrite_backup_policy" "daily" { + name = "daily database backup" + services = ["databases"] + retention = 7 + schedule = "0 2 * * *" +} +``` + +## Scoped to a specific database {% #scoped-backup %} + +```hcl +resource "appwrite_tablesdb" "main" { + name = "main" +} + +resource "appwrite_backup_policy" "production" { + name = "production database backup" + services = ["databases"] + resource_id = appwrite_tablesdb.main.id + retention = 14 + schedule = "0 */6 * * *" +} +``` + +# Related {% #related %} + +- [Databases](/docs/tooling/terraform/resources/databases) - manage databases with Terraform +- [Configuration](/docs/tooling/terraform/provider) diff --git a/src/routes/docs/tooling/terraform/resources/databases/+page.markdoc b/src/routes/docs/tooling/terraform/resources/databases/+page.markdoc index b966f8a44a..317789baa9 100644 --- a/src/routes/docs/tooling/terraform/resources/databases/+page.markdoc +++ b/src/routes/docs/tooling/terraform/resources/databases/+page.markdoc @@ -1,97 +1,110 @@ --- layout: article title: Databases -description: Use Terraform to manage Appwrite databases, tables, columns, and indexes with the official Appwrite provider. +description: Use Terraform to manage Appwrite databases, tables, columns, indexes, and rows with the official Appwrite provider. --- -The provider exposes Appwrite **Tables**-style data modeling as Terraform resources. Typical order: create a **database**, then **tables**, then **columns** and **indexes** that belong to those tables. +The provider exposes Appwrite **Tables**-style data modeling as Terraform resources. Typical order: create a **database**, then **tables**, then **columns** and **indexes** that belong to those tables. You can also seed **rows** once the schema is in place. -For full generated schemas, see the Terraform Registry: [database](https://registry.terraform.io/providers/appwrite/appwrite/latest/docs/resources/database), [table](https://registry.terraform.io/providers/appwrite/appwrite/latest/docs/resources/table), [column](https://registry.terraform.io/providers/appwrite/appwrite/latest/docs/resources/column), and [index](https://registry.terraform.io/providers/appwrite/appwrite/latest/docs/resources/index). The [provider repository](https://github.com/appwrite/terraform-provider-appwrite) contains the source and examples. +For full generated schemas, see the Terraform Registry: [tablesdb](https://registry.terraform.io/providers/appwrite/appwrite/latest/docs/resources/tablesdb), [tablesdb_table](https://registry.terraform.io/providers/appwrite/appwrite/latest/docs/resources/tablesdb_table), [tablesdb_column](https://registry.terraform.io/providers/appwrite/appwrite/latest/docs/resources/tablesdb_column), [tablesdb_index](https://registry.terraform.io/providers/appwrite/appwrite/latest/docs/resources/tablesdb_index), and [tablesdb_row](https://registry.terraform.io/providers/appwrite/appwrite/latest/docs/resources/tablesdb_row). The [provider repository](https://github.com/appwrite/terraform-provider-appwrite) contains the source and examples. # Resources {% #resources %} | Resource | Purpose | |----------|---------| -| `appwrite_database` | Create a database in your project | -| `appwrite_table` | Create a table within a database | -| `appwrite_column` | Define columns (types, constraints, defaults) | -| `appwrite_index` | Add indexes on one or more columns | +| `appwrite_tablesdb` | Create a database in your project | +| `appwrite_tablesdb_table` | Create a table within a database | +| `appwrite_tablesdb_column` | Define columns (types, constraints, defaults) | +| `appwrite_tablesdb_index` | Add indexes on one or more columns | +| `appwrite_tablesdb_row` | Insert a row into a table | -Relationships use `database_id` and `table_id` references, often wired through Terraform resource attributes (for example `appwrite_database.main.id`). +Relationships use `database_id` and `table_id` references, often wired through Terraform resource attributes (for example `appwrite_tablesdb.main.id`). # Example {% #example %} -This pattern matches the upstream documentation: a database, a `users` table, several columns, and a unique index on email. +This pattern matches the upstream documentation: a database, a `users` table, several columns, a unique index on email, and a seed row. ```hcl -resource "appwrite_database" "main" { - id = "main" - name = "Main" +resource "appwrite_tablesdb" "main" { + name = "main" } -resource "appwrite_table" "users" { - database_id = appwrite_database.main.id - id = "users" - name = "Users" +resource "appwrite_tablesdb_table" "users" { + database_id = appwrite_tablesdb.main.id + name = "users" } -resource "appwrite_column" "name" { - database_id = appwrite_database.main.id - table_id = appwrite_table.users.id +resource "appwrite_tablesdb_column" "name" { + database_id = appwrite_tablesdb.main.id + table_id = appwrite_tablesdb_table.users.id key = "name" type = "varchar" size = 255 required = true } -resource "appwrite_column" "email" { - database_id = appwrite_database.main.id - table_id = appwrite_table.users.id +resource "appwrite_tablesdb_column" "email" { + database_id = appwrite_tablesdb.main.id + table_id = appwrite_tablesdb_table.users.id key = "email" type = "email" required = true } -resource "appwrite_column" "age" { - database_id = appwrite_database.main.id - table_id = appwrite_table.users.id +resource "appwrite_tablesdb_column" "age" { + database_id = appwrite_tablesdb.main.id + table_id = appwrite_tablesdb_table.users.id key = "age" type = "integer" min = 0 max = 150 } -resource "appwrite_column" "role" { - database_id = appwrite_database.main.id - table_id = appwrite_table.users.id +resource "appwrite_tablesdb_column" "role" { + database_id = appwrite_tablesdb.main.id + table_id = appwrite_tablesdb_table.users.id key = "role" type = "enum" elements = ["admin", "editor", "viewer"] default = "viewer" } -resource "appwrite_column" "tags" { - database_id = appwrite_database.main.id - table_id = appwrite_table.users.id +resource "appwrite_tablesdb_column" "tags" { + database_id = appwrite_tablesdb.main.id + table_id = appwrite_tablesdb_table.users.id key = "tags" type = "varchar" size = 64 array = true } -resource "appwrite_column" "location" { - database_id = appwrite_database.main.id - table_id = appwrite_table.users.id +resource "appwrite_tablesdb_column" "location" { + database_id = appwrite_tablesdb.main.id + table_id = appwrite_tablesdb_table.users.id key = "location" type = "point" } -resource "appwrite_index" "email_unique" { - database_id = appwrite_database.main.id - table_id = appwrite_table.users.id +resource "appwrite_tablesdb_index" "email_unique" { + database_id = appwrite_tablesdb.main.id + table_id = appwrite_tablesdb_table.users.id key = "email_unique" type = "unique" - columns = [appwrite_column.email.key] + columns = [appwrite_tablesdb_column.email.key] +} + +resource "appwrite_tablesdb_row" "alice" { + database_id = appwrite_tablesdb.main.id + table_id = appwrite_tablesdb_table.users.id + data = jsonencode({ + name = "alice" + email = "alice@example.com" + }) + + depends_on = [ + appwrite_tablesdb_column.name, + appwrite_tablesdb_column.email, + ] } ``` diff --git a/src/routes/docs/tooling/terraform/resources/functions/+page.markdoc b/src/routes/docs/tooling/terraform/resources/functions/+page.markdoc new file mode 100644 index 0000000000..572d36c42f --- /dev/null +++ b/src/routes/docs/tooling/terraform/resources/functions/+page.markdoc @@ -0,0 +1,93 @@ +--- +layout: article +title: Functions +description: Deploy and configure Appwrite serverless functions with Terraform, including runtimes, schedules, event triggers, and environment variables. +--- + +The `appwrite_function` resource manages [Functions](/docs/products/functions) in your Appwrite project: runtimes, entrypoints, build commands, cron schedules, event triggers, execution permissions, and optional VCS integration for automatic deployments. The `appwrite_function_variable` resource sets environment variables on a function. + +See the Terraform Registry for the full attribute list and import syntax: [function](https://registry.terraform.io/providers/appwrite/appwrite/latest/docs/resources/function) and [function_variable](https://registry.terraform.io/providers/appwrite/appwrite/latest/docs/resources/function_variable). The [provider repository](https://github.com/appwrite/terraform-provider-appwrite) has source and examples. + +# Resources {% #resources %} + +| Resource | Purpose | +|----------|---------| +| `appwrite_function` | Create a serverless function | +| `appwrite_function_variable` | Set an environment variable on a function | + +The `runtime` argument accepts values like `node-22`, `python-3.11`, `dart-3.5`, and others supported by your Appwrite version. + +# Examples {% #examples %} + +## Basic function {% #basic-function %} + +```hcl +resource "appwrite_function" "hello_world" { + name = "hello-world" + runtime = "node-22" + entrypoint = "index.js" + commands = "npm install" +} +``` + +## Scheduled function {% #scheduled-function %} + +```hcl +resource "appwrite_function" "daily_cleanup" { + name = "daily-cleanup" + runtime = "node-22" + schedule = "0 0 * * *" + timeout = 60 +} +``` + +## Event-driven function {% #event-driven-function %} + +```hcl +resource "appwrite_function" "on_user_create" { + name = "on-user-create" + runtime = "node-22" + events = ["users.*.create"] + entrypoint = "index.js" + execute = ["any"] +} +``` + +## Environment variables {% #environment-variables %} + +```hcl +resource "appwrite_function_variable" "api_url" { + function_id = appwrite_function.hello_world.id + key = "API_URL" + value = "https://api.example.com" +} + +resource "appwrite_function_variable" "secret_key" { + function_id = appwrite_function.hello_world.id + key = "SECRET_KEY" + value = var.secret_key + secret = true +} +``` + +## VCS integration {% #vcs-integration %} + +Connect a function to a Git repository for automatic deployments on push: + +```hcl +resource "appwrite_function" "api" { + name = "api" + runtime = "node-22" + + installation_id = "your-github-installation-id" + provider_repository_id = "your-repository-id" + provider_branch = "main" + provider_root_directory = "functions/api" +} +``` + +# Related {% #related %} + +- [Functions product docs](/docs/products/functions) +- [Webhooks](/docs/tooling/terraform/resources/webhooks) - trigger external endpoints from events +- [Configuration](/docs/tooling/terraform/provider) diff --git a/src/routes/docs/tooling/terraform/resources/messaging/+page.markdoc b/src/routes/docs/tooling/terraform/resources/messaging/+page.markdoc index 8daabf4d15..59fc1204c4 100644 --- a/src/routes/docs/tooling/terraform/resources/messaging/+page.markdoc +++ b/src/routes/docs/tooling/terraform/resources/messaging/+page.markdoc @@ -14,6 +14,7 @@ See the Terraform Registry for generated schemas: [messaging_provider](https://r |----------|---------| | `appwrite_messaging_provider` | Register an email, SMS, or push provider (Sendgrid, SMTP, Twilio, FCM, and others) | | `appwrite_messaging_topic` | Define a topic for targeting subscribers | +| `appwrite_messaging_subscriber` | Subscribe a target to a topic | The `type` argument on `appwrite_messaging_provider` must be one of the supported provider kinds (for example `sendgrid`, `mailgun`, `smtp`, `resend`, `twilio`, `vonage`, `msg91`, `telesign`, `textmagic`, `apns`, `fcm`). @@ -75,7 +76,16 @@ resource "appwrite_messaging_topic" "alerts" { } ``` -Topics support import by ID; see the upstream docs for details. +## Subscribers {% #subscribers %} + +```hcl +resource "appwrite_messaging_subscriber" "user_email" { + topic_id = appwrite_messaging_topic.announcements.id + target_id = "user-email-target-id" +} +``` + +Topics and subscribers support import by ID; see the upstream docs for details. # Related {% #related %} diff --git a/src/routes/docs/tooling/terraform/resources/sites/+page.markdoc b/src/routes/docs/tooling/terraform/resources/sites/+page.markdoc new file mode 100644 index 0000000000..2baecc9191 --- /dev/null +++ b/src/routes/docs/tooling/terraform/resources/sites/+page.markdoc @@ -0,0 +1,95 @@ +--- +layout: article +title: Sites +description: Host frontends on Appwrite with Terraform, including framework presets, build configuration, and environment variables. +--- + +The `appwrite_site` resource manages [Sites](/docs/products/sites) in your Appwrite project: framework selection, build runtimes, install and build commands, output directories, and optional VCS integration. The `appwrite_site_variable` resource sets environment variables on a site. + +See the Terraform Registry for the full attribute list and import syntax: [site](https://registry.terraform.io/providers/appwrite/appwrite/latest/docs/resources/site) and [site_variable](https://registry.terraform.io/providers/appwrite/appwrite/latest/docs/resources/site_variable). The [provider repository](https://github.com/appwrite/terraform-provider-appwrite) has source and examples. + +# Resources {% #resources %} + +| Resource | Purpose | +|----------|---------| +| `appwrite_site` | Create a hosted site | +| `appwrite_site_variable` | Set an environment variable on a site | + +The `framework` argument accepts `nextjs`, `nuxt`, `sveltekit`, `astro`, `remix`, `analog`, `react`, `vue`, `vite`, `flutter`, and `other`. Use `other` for static sites or unsupported frameworks. + +# Examples {% #examples %} + +## Static site {% #static-site %} + +```hcl +resource "appwrite_site" "landing_page" { + name = "landing-page" + framework = "other" + build_runtime = "node-22" +} +``` + +## Next.js site {% #nextjs-site %} + +```hcl +resource "appwrite_site" "dashboard" { + name = "dashboard" + framework = "nextjs" + build_runtime = "node-22" + install_command = "npm install" + build_command = "npm run build" +} +``` + +## Astro site {% #astro-site %} + +```hcl +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 {% #environment-variables %} + +```hcl +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 {% #vcs-integration %} + +Connect a site to a Git repository for automatic deployments on push: + +```hcl +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" +} +``` + +# Related {% #related %} + +- [Sites product docs](/docs/products/sites) +- [Functions](/docs/tooling/terraform/resources/functions) - serverless backend functions +- [Configuration](/docs/tooling/terraform/provider) diff --git a/src/routes/docs/tooling/terraform/resources/storage/+page.markdoc b/src/routes/docs/tooling/terraform/resources/storage/+page.markdoc index 7cd4f0949e..cdcdf86734 100644 --- a/src/routes/docs/tooling/terraform/resources/storage/+page.markdoc +++ b/src/routes/docs/tooling/terraform/resources/storage/+page.markdoc @@ -1,29 +1,30 @@ --- layout: article title: Storage -description: Manage Appwrite Storage buckets with the Terraform provider, including file limits, extensions, compression, and security options. +description: Manage Appwrite Storage buckets and files with the Terraform provider, including file limits, extensions, compression, and security options. --- -The `appwrite_bucket` resource manages [Storage](/docs/products/storage) buckets in your Appwrite project: file size limits, allowed extensions, compression, image transformations, encryption, and optional antivirus. +The `appwrite_storage_bucket` resource manages [Storage](/docs/products/storage) buckets in your Appwrite project: file size limits, allowed extensions, compression, image transformations, encryption, and optional antivirus. The `appwrite_storage_file` resource uploads files into those buckets. -See the [bucket resource](https://registry.terraform.io/providers/appwrite/appwrite/latest/docs/resources/bucket) on the Terraform Registry for the full attribute list and import syntax, and the [provider repository](https://github.com/appwrite/terraform-provider-appwrite) for source and examples. +See the Terraform Registry for the full attribute list and import syntax: [storage_bucket](https://registry.terraform.io/providers/appwrite/appwrite/latest/docs/resources/storage_bucket) and [storage_file](https://registry.terraform.io/providers/appwrite/appwrite/latest/docs/resources/storage_file). The [provider repository](https://github.com/appwrite/terraform-provider-appwrite) has source and examples. -# Resource {% #resource %} +# Resources {% #resources %} | Resource | Purpose | |----------|---------| -| `appwrite_bucket` | Create and update a storage bucket | +| `appwrite_storage_bucket` | Create and configure a storage bucket | +| `appwrite_storage_file` | Upload a file into a bucket | # Example {% #example %} +## Buckets {% #buckets %} + ```hcl -resource "appwrite_bucket" "uploads" { - id = "uploads" +resource "appwrite_storage_bucket" "uploads" { name = "uploads" } -resource "appwrite_bucket" "images" { - id = "images" +resource "appwrite_storage_bucket" "images" { name = "images" maximum_file_size = 10485760 allowed_file_extensions = ["jpg", "png", "webp", "gif"] @@ -31,8 +32,7 @@ resource "appwrite_bucket" "images" { transformations = true } -resource "appwrite_bucket" "documents" { - id = "documents" +resource "appwrite_storage_bucket" "documents" { name = "documents" file_security = true encryption = true @@ -42,7 +42,28 @@ resource "appwrite_bucket" "documents" { Common optional arguments include `maximum_file_size`, `allowed_file_extensions`, `compression` (`none`, `gzip`, `zstd`), `transformations`, `file_security`, `encryption`, `antivirus`, `enabled`, and `permissions`. Read-only attributes expose `created_at` and `updated_at`. -Buckets support [Terraform import](https://developer.hashicorp.com/terraform/cli/commands/import) using the bucket ID (see upstream examples). +## Files {% #files %} + +```hcl +resource "appwrite_storage_bucket" "assets" { + name = "assets" +} + +resource "appwrite_storage_file" "logo" { + bucket_id = appwrite_storage_bucket.assets.id + name = "logo.png" + file_path = "assets/logo.png" +} + +resource "appwrite_storage_file" "config" { + bucket_id = appwrite_storage_bucket.assets.id + name = "config.json" + file_path = "assets/config.json" + permissions = ["read(\"any\")"] +} +``` + +Buckets and files support [Terraform import](https://developer.hashicorp.com/terraform/cli/commands/import) using their IDs (see upstream examples). # Related {% #related %} diff --git a/src/routes/docs/tooling/terraform/resources/webhooks/+page.markdoc b/src/routes/docs/tooling/terraform/resources/webhooks/+page.markdoc new file mode 100644 index 0000000000..260f5d7ce2 --- /dev/null +++ b/src/routes/docs/tooling/terraform/resources/webhooks/+page.markdoc @@ -0,0 +1,56 @@ +--- +layout: article +title: Webhooks +description: Configure Appwrite webhooks with Terraform for event-driven HTTP callbacks with optional authentication. +--- + +The `appwrite_webhook` resource manages webhooks in your Appwrite project: event filters, target URLs, SSL verification, and optional HTTP authentication. + +See the [webhook resource](https://registry.terraform.io/providers/appwrite/appwrite/latest/docs/resources/webhook) on the Terraform Registry for the full attribute list and import syntax. The [provider repository](https://github.com/appwrite/terraform-provider-appwrite) has source and examples. + +# Resource {% #resource %} + +| Resource | Purpose | +|----------|---------| +| `appwrite_webhook` | Register an event-driven HTTP callback | + +# Examples {% #examples %} + +## Basic webhook {% #basic-webhook %} + +```hcl +resource "appwrite_webhook" "order_created" { + name = "order created" + url = "https://api.example.com/webhooks/orders" + events = ["databases.*.collections.*.documents.*.create"] +} +``` + +## Multiple events {% #multiple-events %} + +```hcl +resource "appwrite_webhook" "user_events" { + name = "user events" + url = "https://api.example.com/webhooks/users" + events = ["users.*.create", "users.*.update", "users.*.delete"] + security = true +} +``` + +## Authenticated webhook {% #authenticated-webhook %} + +```hcl +resource "appwrite_webhook" "authenticated" { + name = "authenticated webhook" + url = "https://api.example.com/webhooks/secure" + events = ["databases.*.collections.*.documents.*.create"] + http_user = "webhook" + http_pass = var.webhook_password + security = true +} +``` + +# Related {% #related %} + +- [Functions](/docs/tooling/terraform/resources/functions) - serverless functions triggered by events +- [Configuration](/docs/tooling/terraform/provider)