|
| 1 | +--- |
| 2 | +page_title: "Resource: appwrite_function_deployment" |
| 3 | +subcategory: "Functions" |
| 4 | +description: |- |
| 5 | + Manages an Appwrite function deployment. |
| 6 | +--- |
| 7 | + |
| 8 | +# Resource: appwrite_function_deployment |
| 9 | + |
| 10 | +Manages an Appwrite function deployment. |
| 11 | + |
| 12 | +Deployments are immutable - any change to input attributes will destroy the existing deployment and create a new one. Use the `wait_for_ready` attribute (default `true`) to wait for the build to complete before Terraform proceeds. |
| 13 | + |
| 14 | +-> **Tip:** Use `code_hash = filesha256("./code.tar.gz")` to trigger a new deployment when your code file changes, even if the file path stays the same. |
| 15 | + |
| 16 | +## Example Usage |
| 17 | + |
| 18 | +### Code Upload |
| 19 | + |
| 20 | +```terraform |
| 21 | +resource "appwrite_function_deployment" "process_order" { |
| 22 | + function_id = appwrite_function.process_order.id |
| 23 | + source_type = "code" |
| 24 | + code_path = "./process-order.tar.gz" |
| 25 | + code_hash = filesha256("./process-order.tar.gz") |
| 26 | + entrypoint = "index.js" |
| 27 | + commands = "npm install" |
| 28 | + activate = true |
| 29 | +} |
| 30 | +``` |
| 31 | + |
| 32 | +### Template |
| 33 | + |
| 34 | +```terraform |
| 35 | +resource "appwrite_function_deployment" "daily_report" { |
| 36 | + function_id = appwrite_function.daily_report.id |
| 37 | + source_type = "template" |
| 38 | + repository = "templates" |
| 39 | + owner = "appwrite" |
| 40 | + root_directory = "node/starter" |
| 41 | + type = "branch" |
| 42 | + reference = "main" |
| 43 | + activate = true |
| 44 | +} |
| 45 | +``` |
| 46 | + |
| 47 | +<!-- schema generated by tfplugindocs --> |
| 48 | +## Schema |
| 49 | + |
| 50 | +### Required |
| 51 | + |
| 52 | +- `function_id` (String) The function ID this deployment belongs to. |
| 53 | +- `source_type` (String) The deployment source type. Must be one of "code" or "template". |
| 54 | + |
| 55 | +### Optional |
| 56 | + |
| 57 | +- `activate` (Boolean) Whether to activate this deployment after creation. |
| 58 | +- `code_hash` (String) Hash of the code file for drift detection. Use filesha256() to compute. |
| 59 | +- `code_path` (String) Local path to the code tar.gz file to upload. Required when source_type is code. |
| 60 | +- `commands` (String) Build commands for code deployments. |
| 61 | +- `entrypoint` (String) The entrypoint file for code deployments. |
| 62 | +- `owner` (String) Repository owner for template deployments. |
| 63 | +- `project_id` (String) The Appwrite project ID. Defaults to the provider-level project_id. |
| 64 | +- `reference` (String) Reference value for template deployments (e.g. branch name, tag, or commit hash). |
| 65 | +- `repository` (String) Repository name for template deployments. |
| 66 | +- `root_directory` (String) Root directory in the repository for template deployments. |
| 67 | +- `type` (String) Reference type for template deployments (e.g. "branch", "tag", "commit"). |
| 68 | +- `wait_for_ready` (Boolean) Whether to wait for the deployment to reach ready status before completing. Defaults to true. |
| 69 | + |
| 70 | +### Read-Only |
| 71 | + |
| 72 | +- `build_duration` (Number) The build duration in seconds. |
| 73 | +- `build_logs` (String) The build logs. |
| 74 | +- `build_size` (Number) The build output size in bytes. |
| 75 | +- `created_at` (String) The deployment creation timestamp in ISO 8601 format. |
| 76 | +- `id` (String) The deployment ID. |
| 77 | +- `source_size` (Number) The source code size in bytes. |
| 78 | +- `status` (String) The deployment build status. |
| 79 | +- `total_size` (Number) The total size in bytes. |
| 80 | +- `updated_at` (String) The deployment last update timestamp in ISO 8601 format. |
| 81 | + |
| 82 | + |
| 83 | + |
| 84 | +~> **NOTE:** Imported deployments will not have `source_type`, `code_path`, or template attributes in state since these are not returned by the API. The imported resource can be read and deleted but not recreated without specifying these attributes. |
| 85 | + |
| 86 | +## See Also |
| 87 | + |
| 88 | +- [appwrite_function](function.md) - Manage functions |
| 89 | +- [appwrite_function_variable](function_variable.md) - Manage function environment variables |
0 commit comments