githubEdit

cubeTerraform Provider

Manage Spice.ai resources with Terraform

The Spice.ai Terraform Providerarrow-up-right enables infrastructure-as-code management of your Spice.ai Cloud resources.

Quick Start

terraform {
  required_providers {
    spiceai = {
      source  = "spiceai/spiceai"
      version = "~> 0.1"
    }
  }
}

provider "spiceai" {}

resource "spiceai_app" "app" {
  name  = "my-spicecloud-app"
  cname = "us-west-2-prod-aws-data"
}

resource "spiceai_deployment" "deploy" {
  app_id = spiceai_app.app.id
}

Authentication

The provider authenticates using OAuth 2.0 Client Credentials. Create an OAuth client in the Spice.ai Portalarrow-up-right under SettingsOAuth Clients.

Set credentials via environment variables (recommended):

Or configure directly in the provider block:

Environment Variables

Variable
Description

SPICEAI_CLIENT_ID

OAuth client ID

SPICEAI_CLIENT_SECRET

OAuth client secret

SPICEAI_API_ENDPOINT

API endpoint (default: https://api.spice.ai)

SPICEAI_OAUTH_ENDPOINT

OAuth token endpoint (default: https://spice.ai/api/oauth/token)

Resources

spiceai_app

Manages a Spice.ai application.

Required arguments:

Argument
Type
Description

name

string

App name (min 4 chars, alphanumeric and hyphens). Forces replacement on change.

cname

string

Region identifier. Get values from the spiceai_regions data source. Forces replacement on change.

Optional arguments:

Argument
Type
Description

description

string

App description

visibility

string

public or private (default: private)

spicepod

string

Spicepod configuration (YAML or JSON string)

image_tag

string

Spice runtime image tag (e.g., latest, v0.18.0)

image

string

Image name for the spiced container

registry

string

Registry for the spiced image

replicas

number

Number of replicas (0–10)

region

string

Deployment region

node_group

string

Node group for deployment

storage_claim_size_gb

number

Persistent volume size in GB

production_branch

string

Git branch for production deployments

update_channel

string

Update channel: stable, nightly, internal, internal-sandbox

tags

map(string)

Key-value tags for the app

Read-only attributes:

Attribute
Description

id

App ID

api_key

Primary API key (sensitive)

cluster_id

Kubernetes cluster identifier

created_at

Timestamp when the app was created

The spicepod can also be provided as JSON or loaded from a template file:

spiceai_deployment

Creates a deployment for a Spice.ai app. Deployments are immutable — any changes create a new deployment.

Required arguments:

Argument
Type
Description

app_id

string

The app ID to deploy

Optional arguments:

Argument
Type
Description

image_tag

string

Override the Spice runtime image tag

replicas

number

Override the number of replicas (0–10)

debug

boolean

Enable debug mode

branch

string

Git branch name

commit_sha

string

Git commit SHA

commit_message

string

Git commit message

triggers

map(string)

Map of values that force a new deployment when changed

Read-only attributes:

Attribute
Description

id

Deployment ID

status

Status: queued, in_progress, succeeded, failed, created

created_at

Timestamp when the deployment was created

started_at

Timestamp when the deployment started running

finished_at

Timestamp when the deployment finished

error_message

Error message if deployment failed

Use triggers to automatically redeploy when app configuration changes:

circle-info

Deployments are append-only. Removing a deployment resource from your configuration only removes it from Terraform state — it will not stop the running instance.

spiceai_secret

Manages secrets for a Spice.ai app. Secret values are encrypted at rest.

Required arguments:

Argument
Type
Description

app_id

number

The app ID

name

string

Secret name. Forces replacement on change.

value

string

Secret value (sensitive)

Read-only attributes:

Attribute
Description

id

Secret ID

created_at

Timestamp when the secret was created

updated_at

Timestamp when the secret was updated

circle-info

After importing a secret, you must set the value attribute in your configuration since secret values are not returned by the API.

spiceai_member

Manages organization members.

Required arguments:

Argument
Type
Description

username

string

Username of the user. Forces replacement on change.

Optional arguments:

Argument
Type
Description

roles

list(string)

Roles to assign (admin, member)

Read-only attributes:

Attribute
Description

id

Member ID (same as user_id)

user_id

User ID

is_owner

Whether the member is the organization owner

created_at

Timestamp when the member was added

circle-exclamation

Data Sources

spiceai_regions

Lists available deployment regions.

Argument
Type
Description

env

string

Optional. Filter by environment: prod or dev

Attribute
Description

default

Default region identifier

regions

List of region objects with cname, region, name, provider, provider_name, is_default, disabled

spiceai_container_images

Lists available Spice runtime container images.

Argument
Type
Description

channel

string

Optional. Release channel: stable or enterprise (default: stable)

Attribute
Description

default

Default image tag

images

List of image objects with tag, name, channel

spiceai_api_keys

Retrieves the API keys for an app. Each app has two API keys to support key rotation.

Argument
Type
Description

app_id

string

Required. The app ID

Attribute
Description

api_key

Primary API key (sensitive)

api_key_2

Secondary API key (sensitive)

spiceai_app

Gets details about an existing app by ID.

spiceai_apps

Lists all apps in the organization.

spiceai_members

Lists all organization members.

spiceai_secrets

Lists secrets for an app (values are masked).

Import

Import existing resources into Terraform state:

Complete Example

See also:

Last updated

Was this helpful?