11# Terraform Provider for Spice.ai
22
3- This Terraform provider allows you to manage [ Spice.ai] ( https://spice.ai ) resources including apps, app configurations, and deployments.
3+ This Terraform provider allows you to manage [ Spice.ai Cloud ] ( https://spice.ai ) resources including apps and deployments.
44
55## Requirements
66
@@ -61,75 +61,62 @@ provider "spiceai" {
6161
6262### spiceai_app
6363
64- Manages a Spice.ai app.
64+ Manages a Spice.ai app and its configuration. This resource combines app creation with spicepod and runtime configuration .
6565
6666``` hcl
6767resource "spiceai_app" "example" {
6868 name = "my-app"
6969 description = "My Spice.ai application"
70- visibility = "private" # or "public"
71- }
72- ```
73-
74- #### Attributes
75-
76- | Name | Type | Required | Description |
77- | ------| ------| ----------| -------------|
78- | ` name ` | string | Yes | The name of the app (min 4 chars, alphanumeric and hyphens only) |
79- | ` description ` | string | No | A description of the app |
80- | ` visibility ` | string | No | The visibility (` public ` or ` private ` , default: ` private ` ) |
81-
82- #### Read-Only Attributes
83-
84- - ` id ` - The unique identifier of the app
85- - ` region ` - The region where the app is deployed
86- - ` created_at ` - Timestamp when the app was created
87- - ` api_key ` - The API key for the app (sensitive)
88-
89- ### spiceai_app_config
90-
91- Applies configuration to a Spice.ai app.
92-
93- ``` hcl
94- resource "spiceai_app_config" "example" {
95- app_id = spiceai_app.example.id
70+ visibility = "private"
9671
72+ # Spicepod configuration (YAML or JSON)
9773 spicepod = <<-YAML
9874 version: v1beta1
9975 kind: Spicepod
10076 name: my-app
10177 datasets:
102- - name: my_dataset
103- from: s3://bucket/path/
78+ - name: taxi_trips
79+ from: s3://spiceai-demo-datasets/taxi_trips/2024/
80+ params:
81+ file_format: parquet
10482 YAML
10583
106- image_tag = "latest"
107- replicas = 2
108- node_group = "default"
109- region = "us-east-1"
84+ # Runtime configuration
85+ image_tag = "latest"
86+ replicas = 2
87+ node_group = "default"
88+ region = "us-east-1"
11089 storage_claim_size_gb = 10.0
111- production_branch = "main"
90+ production_branch = "main"
11291}
11392```
11493
115- #### Attributes
94+ #### Arguments
11695
11796| Name | Type | Required | Description |
11897| ------| ------| ----------| -------------|
119- | ` app_id ` | string | Yes | The ID of the app to configure |
120- | ` spicepod ` | string | No | Spicepod configuration (YAML or JSON) |
121- | ` image_tag ` | string | No | Spice.ai runtime image tag |
98+ | ` name ` | string | Yes | The name of the app (min 4 chars, alphanumeric and hyphens only). Changing this forces a new resource. |
99+ | ` description ` | string | No | A description of the app |
100+ | ` visibility ` | string | No | The visibility (` public ` or ` private ` , default: ` private ` ) |
101+ | ` spicepod ` | string | No | Spicepod configuration (YAML or JSON string) |
102+ | ` image_tag ` | string | No | Spice.ai runtime image tag (e.g., ` latest ` , ` v0.18.0 ` ) |
122103| ` replicas ` | int | No | Number of replicas (1-10) |
123104| ` node_group ` | string | No | Node group for deployment |
124105| ` region ` | string | No | Deployment region |
125106| ` storage_claim_size_gb ` | float | No | Storage claim size in GB |
126- | ` production_branch ` | string | No | Production branch name |
127- | ` description ` | string | No | App description |
128- | ` visibility ` | string | No | App visibility |
107+ | ` production_branch ` | string | No | Production branch name for git-based deployments |
108+
109+ #### Read-Only Attributes
110+
111+ | Name | Description |
112+ | ------| -------------|
113+ | ` id ` | The unique identifier of the app |
114+ | ` created_at ` | Timestamp when the app was created |
115+ | ` api_key ` | The API key for the app (sensitive) |
129116
130117### spiceai_deployment
131118
132- Creates a deployment for a Spice.ai app.
119+ Creates a deployment for a Spice.ai app. Deployments are immutable - any changes will trigger creation of a new deployment.
133120
134121``` hcl
135122resource "spiceai_deployment" "example" {
@@ -142,39 +129,39 @@ resource "spiceai_deployment" "example" {
142129 commit_sha = "abc123def456"
143130 commit_message = "Deploy from Terraform"
144131 debug = false
145-
146- depends_on = [spiceai_app_config.example]
147132}
148133```
149134
150- #### Attributes
135+ #### Arguments
151136
152137| Name | Type | Required | Description |
153138| ------| ------| ----------| -------------|
154- | ` app_id ` | string | Yes | The ID of the app to deploy |
155- | ` image_tag ` | string | No | Override image tag for this deployment |
156- | ` replicas ` | int | No | Override replicas (1-10) |
157- | ` branch ` | string | No | Git branch name |
158- | ` commit_sha ` | string | No | Git commit SHA |
159- | ` commit_message ` | string | No | Git commit message |
160- | ` debug ` | bool | No | Enable debug mode (default: false) |
139+ | ` app_id ` | string | Yes | The ID of the app to deploy. Changing this forces a new deployment. |
140+ | ` image_tag ` | string | No | Override image tag for this deployment. Changing this forces a new deployment. |
141+ | ` replicas ` | int | No | Override replicas (1-10). Changing this forces a new deployment. |
142+ | ` branch ` | string | No | Git branch name. Changing this forces a new deployment. |
143+ | ` commit_sha ` | string | No | Git commit SHA. Changing this forces a new deployment. |
144+ | ` commit_message ` | string | No | Git commit message. Changing this forces a new deployment. |
145+ | ` debug ` | bool | No | Enable debug mode (default: false). Changing this forces a new deployment. |
161146
162147#### Read-Only Attributes
163148
164- - ` id ` - The unique identifier of the deployment
165- - ` status ` - Current status (` queued ` , ` deploying ` , ` running ` , ` failed ` , ` stopped ` )
166- - ` created_at ` - Timestamp when the deployment was created
167- - ` started_at ` - Timestamp when the deployment started
168- - ` finished_at ` - Timestamp when the deployment finished
169- - ` error_message ` - Error message if deployment failed
149+ | Name | Description |
150+ | ------| -------------|
151+ | ` id ` | The unique identifier of the deployment |
152+ | ` status ` | Current status (` queued ` , ` deploying ` , ` running ` , ` failed ` , ` stopped ` ) |
153+ | ` created_at ` | Timestamp when the deployment was created |
154+ | ` started_at ` | Timestamp when the deployment started running |
155+ | ` finished_at ` | Timestamp when the deployment finished |
156+ | ` error_message ` | Error message if deployment failed |
170157
171158> ** Note:** Deployments are immutable. Any changes to deployment parameters will trigger a replacement (new deployment).
172159
173160## Data Sources
174161
175162### spiceai_app
176163
177- Retrieves details about an existing app.
164+ Retrieves details about an existing app by ID .
178165
179166``` hcl
180167data "spiceai_app" "example" {
@@ -184,6 +171,10 @@ data "spiceai_app" "example" {
184171output "app_name" {
185172 value = data.spiceai_app.example.name
186173}
174+
175+ output "app_replicas" {
176+ value = data.spiceai_app.example.replicas
177+ }
187178```
188179
189180### spiceai_apps
@@ -196,6 +187,10 @@ data "spiceai_apps" "all" {}
196187output "app_names" {
197188 value = [for app in data.spiceai_apps.all.apps : app.name]
198189}
190+
191+ output "private_apps" {
192+ value = [for app in data.spiceai_apps.all.apps : app.name if app.visibility == "private"]
193+ }
199194```
200195
201196## Example Usage
@@ -210,18 +205,16 @@ terraform {
210205 }
211206}
212207
213- provider "spiceai" {}
208+ provider "spiceai" {
209+ # Credentials are read from environment variables:
210+ # SPICEAI_CLIENT_ID and SPICEAI_CLIENT_SECRET
211+ }
214212
215- # Create an app
213+ # Create an app with configuration
216214resource "spiceai_app" "example" {
217215 name = "my-terraform-app"
218216 description = "Managed by Terraform"
219217 visibility = "private"
220- }
221-
222- # Configure the app with a spicepod
223- resource "spiceai_app_config" "example" {
224- app_id = spiceai_app.example.id
225218
226219 spicepod = <<-YAML
227220 version: v1beta1
@@ -232,22 +225,26 @@ resource "spiceai_app_config" "example" {
232225 from: s3://spiceai-demo-datasets/taxi_trips/2024/
233226 params:
234227 file_format: parquet
235- YAML
228+ YAML
236229
237- replicas = 1
230+ image_tag = "latest"
231+ replicas = 1
238232}
239233
240234# Deploy the app
241235resource "spiceai_deployment" "example" {
242236 app_id = spiceai_app.example.id
243-
244- depends_on = [spiceai_app_config.example]
245237}
246238
247239output "app_id" {
248240 value = spiceai_app.example.id
249241}
250242
243+ output "app_api_key" {
244+ value = spiceai_app.example.api_key
245+ sensitive = true
246+ }
247+
251248output "deployment_status" {
252249 value = spiceai_deployment.example.status
253250}
@@ -261,9 +258,6 @@ Resources can be imported using their IDs:
261258# Import an app
262259terraform import spiceai_app.example 12345
263260
264- # Import an app config (uses app ID)
265- terraform import spiceai_app_config.example 12345
266-
267261# Import a deployment (format: app_id/deployment_id)
268262terraform import spiceai_deployment.example 12345/67890
269263```
@@ -295,6 +289,12 @@ provider_installation {
295289}
296290```
297291
292+ ### Generating Documentation
293+
294+ ``` bash
295+ go generate ./...
296+ ```
297+
298298## License
299299
300300MPL-2.0. See [ LICENSE] ( LICENSE ) file.
0 commit comments