Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 89 additions & 0 deletions docs/resources/dedicated_database.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
---
page_title: "Resource: appwrite_dedicated_database"
description: |-
Manages an Appwrite dedicated database (a managed PostgreSQL, MySQL, or MongoDB instance).
---

# Resource: appwrite_dedicated_database

Manages an Appwrite dedicated database (a managed PostgreSQL, MySQL, or MongoDB instance).

## Example Usage

```terraform
resource "appwrite_dedicated_database" "postgres" {
engine = "postgresql"
name = "analytics"
version = "16"
specification = "s-1vcpu-2gb"
}

resource "appwrite_dedicated_database" "highly_available" {
engine = "mysql"
name = "orders"
specification = "s-2vcpu-4gb"
replicas = 2
sync_mode = "sync"
pitr = true
pitr_retention_days = 7
storage_autoscaling = true
network_ip_allowlist = ["10.0.0.0/8"]
}

# Connection details are computed once the database finishes provisioning.
output "orders_connection_string" {
value = appwrite_dedicated_database.highly_available.connection_string
sensitive = true
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `engine` (String) The database engine. One of: mongo, mysql, postgresql.
- `name` (String) The database display name.

### Optional

- `api` (String) The product API that owns this database: nativedb, documentsdb, or vectorsdb. Changing this forces a new database.
- `id` (String) The dedicated database ID. Must be unique within the project.
- `idle_timeout_minutes` (Number) Minutes of inactivity before the container scales to zero.
- `network_idle_timeout_seconds` (Number) Connection idle timeout in seconds.
- `network_ip_allowlist` (List of String) IP addresses/CIDR ranges allowed to connect.
- `pitr` (Boolean) Whether point-in-time recovery is enabled.
- `pitr_retention_days` (Number) Number of days to retain point-in-time-recovery data.
- `project_id` (String) The Appwrite project ID. Defaults to the provider-level project_id.
- `replicas` (Number) Number of high-availability replicas. High availability is enabled when greater than 0.
- `specification` (String) The compute specification identifier (e.g. a size tier). See the engine's list-specifications API for valid values.
- `storage_autoscaling` (Boolean) Whether automatic storage expansion is enabled.
- `storage_autoscaling_max_gb` (Number) Maximum storage size in GB for autoscaling. 0 means no limit.
- `storage_autoscaling_threshold_percent` (Number) Storage usage percentage that triggers automatic expansion.
- `sync_mode` (String) Replication sync mode: async, sync, or quorum.
- `version` (String) The engine version. Changing this forces a new database; use the Appwrite console to perform an in-place upgrade.

### Read-Only

- `backend` (String) Database backend provider (prisma or edge).
- `connection_password` (String, Sensitive) Database password for connections.
- `connection_port` (Number) Database port for connections.
- `connection_string` (String, Sensitive) Full database connection string (URI format).
- `connection_user` (String) Database username for connections.
- `cpu` (Number) CPU allocated in millicores.
- `created_at` (String) The database creation timestamp in ISO 8601 format.
- `hostname` (String) Database hostname for connections.
- `memory` (Number) Memory allocated in MB.
- `ssl` (Boolean) Whether SSL/TLS is required for client connections.
- `status` (String) Database status (e.g. provisioning, ready, paused, failed).
- `storage` (Number) Storage allocated in GB.
- `updated_at` (String) The database last update timestamp in ISO 8601 format.

## Import

Import is supported using the following syntax:

```shell
# Dedicated databases are imported as "engine/database_id".
terraform import appwrite_dedicated_database.postgres postgresql/6812a1b2c3d4e5f6a7b8
```
54 changes: 54 additions & 0 deletions docs/resources/dedicated_database_backup_policy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
page_title: "Resource: appwrite_dedicated_database_backup_policy"
description: |-
Manages a backup policy for an Appwrite dedicated database.
---

# Resource: appwrite_dedicated_database_backup_policy

Manages a backup policy for an Appwrite dedicated database.

## Example Usage

```terraform
resource "appwrite_dedicated_database_backup_policy" "daily" {
engine = appwrite_dedicated_database.postgres.engine
database_id = appwrite_dedicated_database.postgres.id
name = "daily"
schedule = "0 3 * * *"
retention = 30
type = "full"
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `database_id` (String) The dedicated database this policy backs up.
- `engine` (String) The engine of the target database. One of: mongo, mysql, postgresql.
- `name` (String) The backup policy name.
- `retention` (Number) How many days to keep each backup before automatic deletion.
- `schedule` (String) Backup schedule in CRON format.

### Optional

- `enabled` (Boolean) Whether the policy is enabled. Defaults to true.
- `id` (String) The backup policy ID.
- `project_id` (String) The Appwrite project ID. Defaults to the provider-level project_id.
- `type` (String) The backup type (e.g. full). Changing this forces a new policy.

### Read-Only

- `created_at` (String) The policy creation timestamp in ISO 8601 format.
- `updated_at` (String) The policy last update timestamp in ISO 8601 format.

## Import

Import is supported using the following syntax:

```shell
# Backup policies are imported as "engine/database_id/policy_id".
terraform import appwrite_dedicated_database_backup_policy.daily postgresql/6812a1b2c3d4e5f6a7b8/6900aabbccddeeff0011
```
2 changes: 2 additions & 0 deletions examples/resources/appwrite_dedicated_database/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Dedicated databases are imported as "engine/database_id".
terraform import appwrite_dedicated_database.postgres postgresql/6812a1b2c3d4e5f6a7b8
24 changes: 24 additions & 0 deletions examples/resources/appwrite_dedicated_database/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
resource "appwrite_dedicated_database" "postgres" {
engine = "postgresql"
name = "analytics"
version = "16"
specification = "s-1vcpu-2gb"
}

resource "appwrite_dedicated_database" "highly_available" {
engine = "mysql"
name = "orders"
specification = "s-2vcpu-4gb"
replicas = 2
sync_mode = "sync"
pitr = true
pitr_retention_days = 7
storage_autoscaling = true
network_ip_allowlist = ["10.0.0.0/8"]
}

# Connection details are computed once the database finishes provisioning.
output "orders_connection_string" {
value = appwrite_dedicated_database.highly_available.connection_string
sensitive = true
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Backup policies are imported as "engine/database_id/policy_id".
terraform import appwrite_dedicated_database_backup_policy.daily postgresql/6812a1b2c3d4e5f6a7b8/6900aabbccddeeff0011
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
resource "appwrite_dedicated_database_backup_policy" "daily" {
engine = appwrite_dedicated_database.postgres.engine
database_id = appwrite_dedicated_database.postgres.id
name = "daily"
schedule = "0 3 * * *"
retention = 30
type = "full"
}
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ require (
github.com/agext/levenshtein v1.2.2 // indirect
github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect
github.com/armon/go-radix v1.0.0 // indirect
github.com/aw-tests/sdk-for-go/v6 v6.0.0-20260717085122-b0c41417939c
github.com/bgentry/speakeasy v0.1.0 // indirect
github.com/bmatcuk/doublestar/v4 v4.9.1 // indirect
github.com/cloudflare/circl v1.6.1 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ github.com/appwrite/sdk-for-go/v6 v6.0.0 h1:npGhGJNhvWx8DN7OdxTap5g22wknVSTUHAkp
github.com/appwrite/sdk-for-go/v6 v6.0.0/go.mod h1:5oTdAwNsSNCY0FxwUzs1J0XAgxue2veWSdVcCSsKg8I=
github.com/armon/go-radix v1.0.0 h1:F4z6KzEeeQIMeLFa97iZU6vupzoecKdU5TX24SNppXI=
github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
github.com/aw-tests/sdk-for-go/v6 v6.0.0-20260717085122-b0c41417939c h1:Wu9yfIzioyOd9epEkwo+EW7AYl/BUsMiajRX3H7xTao=
github.com/aw-tests/sdk-for-go/v6 v6.0.0-20260717085122-b0c41417939c/go.mod h1:DQqf5bOjLP3TkP+AQXH8OJWiSBQt3jGB6QzTshKOFSs=
github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQkY=
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
github.com/bmatcuk/doublestar/v4 v4.9.1 h1:X8jg9rRZmJd4yRy7ZeNDRnM+T3ZfHv15JiBJ/avrEXE=
Expand Down
8 changes: 8 additions & 0 deletions internal/common/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ type AppwriteClients struct {
BaseOptions []client.ClientOption
// ProjectID is the provider-level default project ID.
ProjectID string

// Raw credentials, exposed so services built against a different SDK module
// (e.g. the unreleased dedicated-databases fork) can construct their own
// client without re-plumbing the provider config.
Endpoint string
APIKey string
SelfSigned bool
UserAgent string
}

// WithUserAgent returns a ClientOption that sets the User-Agent header to identify
Expand Down
8 changes: 8 additions & 0 deletions internal/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package provider

import (
"context"
"fmt"
"os"

"github.com/appwrite/sdk-for-go/v6/appwrite"
Expand All @@ -17,6 +18,7 @@ import (
bucketsvc "github.com/appwrite/terraform-provider-appwrite/internal/services/bucket"
columnsvc "github.com/appwrite/terraform-provider-appwrite/internal/services/column"
databasesvc "github.com/appwrite/terraform-provider-appwrite/internal/services/database"
dedicateddbsvc "github.com/appwrite/terraform-provider-appwrite/internal/services/dedicateddatabase"
filesvc "github.com/appwrite/terraform-provider-appwrite/internal/services/file"
functionsvc "github.com/appwrite/terraform-provider-appwrite/internal/services/function"
indexsvc "github.com/appwrite/terraform-provider-appwrite/internal/services/index"
Expand Down Expand Up @@ -119,6 +121,10 @@ func (p *appwriteProvider) Configure(ctx context.Context, req provider.Configure
clients := &common.AppwriteClients{
BaseOptions: baseOpts,
ProjectID: projectID,
Endpoint: endpoint,
APIKey: apiKey,
SelfSigned: !config.SelfSigned.IsNull() && config.SelfSigned.ValueBool(),
UserAgent: fmt.Sprintf("terraform-provider-appwrite/%s", p.version),
}

resp.DataSourceData = clients
Expand All @@ -128,6 +134,8 @@ func (p *appwriteProvider) Configure(ctx context.Context, req provider.Configure
func (p *appwriteProvider) Resources(_ context.Context) []func() resource.Resource {
return []func() resource.Resource{
databasesvc.NewDatabaseResource,
dedicateddbsvc.NewDatabaseResource,
dedicateddbsvc.NewBackupPolicyResource,
tablesvc.NewTableResource,
columnsvc.NewColumnResource,
indexsvc.NewIndexResource,
Expand Down
Loading