Skip to content

Commit 4da0e0b

Browse files
committed
Add example usage for data sources and update docs
- Add example usage sections to API keys, container images, and regions data source docs - Add corresponding Terraform example files for each data source - Update .gitignore to include Terraform state and lock files - Update .terraformrc.example with placeholder provider path - Remove obsolete .terraform.lock.hcl from local-spice-api example
1 parent 3a33e99 commit 4da0e0b

9 files changed

Lines changed: 152 additions & 13 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ website/node_modules
1616
*.backup
1717
./*.tfstate
1818
.terraform/
19+
.terraform.lock.hcl
20+
terraform.tfstate
1921
*.log
2022
*.bak
2123
*~

docs/data-sources/api_keys.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,28 @@ description: |-
1010

1111
Retrieves the API keys for a Spice.ai app. Each app has two API keys to support key rotation.
1212

13-
13+
## Example Usage
14+
15+
```terraform
16+
# Get API keys for an app
17+
data "spiceai_api_keys" "example" {
18+
app_id = spiceai_app.example.id
19+
}
20+
21+
# Use the primary API key
22+
output "primary_api_key" {
23+
description = "The primary API key for the app"
24+
value = data.spiceai_api_keys.example.api_key
25+
sensitive = true
26+
}
27+
28+
# Use the secondary API key (useful for key rotation)
29+
output "secondary_api_key" {
30+
description = "The secondary API key for the app"
31+
value = data.spiceai_api_keys.example.api_key_2
32+
sensitive = true
33+
}
34+
```
1435

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

docs/data-sources/container_images.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,31 @@ description: |-
1010

1111
Retrieves a list of available Spice.ai runtime container images.
1212

13-
13+
## Example Usage
14+
15+
```terraform
16+
# Get available stable container images
17+
data "spiceai_container_images" "stable" {
18+
channel = "stable"
19+
}
20+
21+
# Get available enterprise container images
22+
data "spiceai_container_images" "enterprise" {
23+
channel = "enterprise"
24+
}
25+
26+
# Output the default image tag
27+
output "default_image_tag" {
28+
description = "The default container image tag"
29+
value = data.spiceai_container_images.stable.default
30+
}
31+
32+
# Output all available image tags
33+
output "available_image_tags" {
34+
description = "List of available container image tags"
35+
value = [for image in data.spiceai_container_images.stable.images : image.tag]
36+
}
37+
```
1438

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

docs/data-sources/regions.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,40 @@ description: |-
1010

1111
Retrieves a list of available deployment regions for Spice.ai apps.
1212

13+
## Example Usage
1314

15+
```terraform
16+
# Get all available deployment regions
17+
data "spiceai_regions" "all" {}
18+
19+
# Get only production regions
20+
data "spiceai_regions" "prod" {
21+
env = "prod"
22+
}
23+
24+
# Output the default region
25+
output "default_region" {
26+
description = "The default deployment region"
27+
value = data.spiceai_regions.all.default
28+
}
29+
30+
# Output all available region identifiers
31+
output "available_regions" {
32+
description = "List of available deployment regions"
33+
value = [for region in data.spiceai_regions.all.regions : region.region]
34+
}
35+
36+
# Output region details
37+
output "regions_info" {
38+
description = "Detailed information about available regions"
39+
value = [for region in data.spiceai_regions.all.regions : {
40+
name = region.name
41+
region = region.region
42+
cname = region.cname
43+
provider = region.provider_name
44+
}]
45+
}
46+
```
1447

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

examples/.terraformrc.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
provider_installation {
1212
dev_overrides {
1313
# Update this path to where your terraform-provider-spiceai binary is located
14-
"spiceai/spiceai" = "/Users/evgenii/Developer/Spice/terraform-provider-spiceai"
14+
"spiceai/spiceai" = "/path/to/terraform-provider-spiceai"
1515
}
1616

1717
# Fall back to the default installation behavior for all other providers
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Get API keys for an app
2+
data "spiceai_api_keys" "example" {
3+
app_id = spiceai_app.example.id
4+
}
5+
6+
# Use the primary API key
7+
output "primary_api_key" {
8+
description = "The primary API key for the app"
9+
value = data.spiceai_api_keys.example.api_key
10+
sensitive = true
11+
}
12+
13+
# Use the secondary API key (useful for key rotation)
14+
output "secondary_api_key" {
15+
description = "The secondary API key for the app"
16+
value = data.spiceai_api_keys.example.api_key_2
17+
sensitive = true
18+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Get available stable container images
2+
data "spiceai_container_images" "stable" {
3+
channel = "stable"
4+
}
5+
6+
# Get available enterprise container images
7+
data "spiceai_container_images" "enterprise" {
8+
channel = "enterprise"
9+
}
10+
11+
# Output the default image tag
12+
output "default_image_tag" {
13+
description = "The default container image tag"
14+
value = data.spiceai_container_images.stable.default
15+
}
16+
17+
# Output all available image tags
18+
output "available_image_tags" {
19+
description = "List of available container image tags"
20+
value = [for image in data.spiceai_container_images.stable.images : image.tag]
21+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Get all available deployment regions
2+
data "spiceai_regions" "all" {}
3+
4+
# Get only production regions
5+
data "spiceai_regions" "prod" {
6+
env = "prod"
7+
}
8+
9+
# Output the default region
10+
output "default_region" {
11+
description = "The default deployment region"
12+
value = data.spiceai_regions.all.default
13+
}
14+
15+
# Output all available region identifiers
16+
output "available_regions" {
17+
description = "List of available deployment regions"
18+
value = [for region in data.spiceai_regions.all.regions : region.region]
19+
}
20+
21+
# Output region details
22+
output "regions_info" {
23+
description = "Detailed information about available regions"
24+
value = [for region in data.spiceai_regions.all.regions : {
25+
name = region.name
26+
region = region.region
27+
cname = region.cname
28+
provider = region.provider_name
29+
}]
30+
}

examples/local-spice-api/.terraform.lock.hcl

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)