Skip to content

Latest commit

 

History

History
254 lines (197 loc) · 8.01 KB

File metadata and controls

254 lines (197 loc) · 8.01 KB
page_title spiceai_app Resource - spiceai
subcategory
description Manages a Spice.ai app and its configuration. Apps are the primary organizational unit in Spice.ai for deploying and managing spicepods. This resource creates an app and configures its spicepod, runtime settings, and deployment parameters. Example Usage resource "spiceai_app" "example" { name = "my-terraform-app" description = "An app created and managed by Terraform" visibility = "private" cname = "us-west-2-prod-aws-data" # Required: region identifier from spiceai_regions data source # Spicepod configuration (YAML or JSON) spicepod = <<-YAML version: v1 kind: Spicepod name: my-app datasets: - name: taxi_trips from: s3://spiceai-demo-datasets/taxi_trips/2024/ params: file_format: parquet YAML # Runtime configuration image_tag = "latest" replicas = 2 node_group = "default" region = "us-east-2" storage_claim_size_gb = 10.0 production_branch = "main" }

spiceai_app (Resource)

Manages a Spice.ai app and its configuration.

Apps are the primary organizational unit in Spice.ai for deploying and managing spicepods. This resource creates an app and configures its spicepod, runtime settings, and deployment parameters.

Example Usage

resource "spiceai_app" "example" {
  name        = "my-terraform-app"
  description = "An app created and managed by Terraform"
  visibility  = "private"
  cname       = "us-west-2-prod-aws-data"  # Required: region identifier from spiceai_regions data source

  # Spicepod configuration (YAML or JSON)
  spicepod = <<-YAML
    version: v1
    kind: Spicepod
    name: my-app
    datasets:
      - name: taxi_trips
        from: s3://spiceai-demo-datasets/taxi_trips/2024/
        params:
          file_format: parquet
  YAML

  # Runtime configuration
  image_tag             = "latest"
  replicas              = 2
  node_group            = "default"
  region                = "us-east-2"
  storage_claim_size_gb = 10.0
  production_branch     = "main"
}

Example Usage

# Basic app with minimal configuration
resource "spiceai_app" "basic" {
  name        = "my-basic-app"
  description = "A basic Spice.ai app"
  visibility  = "private"
  cname       = "us-west-2-prod-aws-data" # Required: region identifier from spiceai_regions data source
}

# Full app with spicepod and runtime configuration
resource "spiceai_app" "full" {
  name        = "my-full-app"
  description = "A fully configured Spice.ai app"
  visibility  = "private"
  cname       = "us-west-2-prod-aws-data"

  # Spicepod configuration (YAML or JSON)
  spicepod = <<-YAML
    version: v1
    kind: Spicepod
    name: my-full-app
    datasets:
      - name: taxi_trips
        from: s3://spiceai-demo-datasets/taxi_trips/2024/
        params:
          file_format: parquet
    models:
      - name: my_model
        from: openai:gpt-4
  YAML

  # Runtime configuration
  image_tag             = "latest"
  replicas              = 2
  node_group            = "default"
  region                = "us-east-2"
  storage_claim_size_gb = 10.0
  production_branch     = "main"
}

# App with JSON spicepod configuration
resource "spiceai_app" "json_config" {
  name        = "my-json-app"
  description = "An app with JSON spicepod configuration"
  visibility  = "public"
  cname       = "us-west-2-prod-aws-data"

  spicepod = jsonencode({
    version = "v1"
    kind    = "Spicepod"
    name    = "my-json-app"
    datasets = [
      {
        name = "my_dataset"
        from = "postgres://mydb/table"
      }
    ]
  })

  replicas = 1
}

# App using regions data source to get cname
data "spiceai_regions" "available" {}

resource "spiceai_app" "with_region_lookup" {
  name        = "my-dynamic-region-app"
  description = "An app using dynamic region lookup"
  visibility  = "private"
  cname       = data.spiceai_regions.available.regions[0].cname
}

Schema

Required

  • cname (String) The region identifier (cname) for the app. This is required when creating an app and determines where the app is deployed. Get available values from the spiceai_regions data source. Changing this forces a new resource to be created.
  • name (String) The name of the app. Must be at least 4 characters and contain only letters, numbers, and hyphens. Changing this forces a new resource to be created.

Optional

  • description (String) A description of the app.
  • executor (Attributes) Executor container configuration. (see below for nested schema)
  • image (String) Image name for the spiced container.
  • image_tag (String) The Spice.ai runtime image tag to use for deployments (e.g., latest, v0.18.0).
  • node_group (String) The node group for the app deployment.
  • production_branch (String) The production branch for the app. Used for git-based deployments.
  • region (String) The region for the app deployment.
  • registry (String) Registry for the spiced image.
  • replicas (Number) The number of replicas for the app. Must be between 0 and 10.
  • resources (Attributes) Resource requests and limits for the app container. (see below for nested schema)
  • spicepod (String) The spicepod configuration as a YAML or JSON string. This defines the datasets, models, and other spicepod settings for the app.
  • storage_claim_size_gb (Number) The storage claim size in GB for the app.
  • tags (Map of String) Key-value tags for the app.
  • update_channel (String) Update channel for the spicepod. Valid values are stable, preview, nightly, and internal.
  • visibility (String) The visibility of the app. Valid values are public or private. Defaults to private.

Read-Only

  • cluster_id (String) The Kubernetes cluster identifier where the app is deployed.
  • created_at (String) The timestamp when the app was created.
  • id (String) The unique identifier of the app.

Nested Schema for executor

Optional:

Nested Schema for executor.resources

Optional:

Nested Schema for executor.resources.limits

Optional:

  • cpu (String) Whole-number vCPU limit, or - for no CPU limit.
  • ephemeral_storage (String) Ephemeral storage limit in Gi (for example, 8Gi).
  • memory (String) Memory limit in Gi (for example, 16Gi).

Nested Schema for executor.resources.requests

Optional:

  • cpu (String)
  • memory (String)

Nested Schema for resources

Optional:

Nested Schema for resources.limits

Optional:

  • cpu (String) Whole-number vCPU limit, or - for no CPU limit.
  • ephemeral_storage (String) Ephemeral storage limit in Gi (for example, 8Gi).
  • memory (String) Memory limit in Gi (for example, 16Gi).

Nested Schema for resources.requests

Optional:

  • cpu (String)
  • memory (String)

Import

Import is supported using the following syntax:

The terraform import command can be used, for example:

# Import an app using its ID
terraform import spiceai_app.example 12345