Provider
The provider manages a workspace's configuration through the
resource API. Each resource maps to one API
kind, and its attributes are the kind's fields in snake case, as passesTo
is passes_to. The fields are described on each kind's page, which names any
other difference; the provider's own generated documentation lists every
attribute.
Source
terraform {
required_providers {
spotlight = {
source = "usespotlightai/spotlight"
}
}
}Provider configuration
| Attribute | Type | Default | Description |
|---|---|---|---|
url | string | none | The Spotlight address, https://app.usespotlight.ai or a self-hosted deployment's address. Without it, the SPOTLIGHT_URL environment variable. |
token | string | none | Sensitive. A stored workspace token. Without it, the SPOTLIGHT_API_TOKEN environment variable. |
oidc.trust | string | none | The id of a workspace token trust to exchange through. Without it, the SPOTLIGHT_OIDC_TRUST environment variable. |
oidc.token | string | none | Sensitive. The OIDC token the CI platform issued the job. Without it, the SPOTLIGHT_OIDC_TOKEN environment variable; in GitHub Actions, one is requested for each exchange. |
oidc.audience | string | none | The audience to request the OIDC token for. Must equal the trust's audience. Without it, the SPOTLIGHT_OIDC_AUDIENCE environment variable, else spotlight. |
- A token and a trust are exclusive. With both, configuration fails with
Both a token and an OIDC trust. urlandtokenmust be known when Terraform plans.- A token minted through a trust is renewed one minute before it expires, and
exchanged again when Spotlight refuses it with
401. - In GitHub Actions, the job needs
permissions: id-token: write; the provider readsACTIONS_ID_TOKEN_REQUEST_URLandACTIONS_ID_TOKEN_REQUEST_TOKENto request the OIDC token. - Every request carries
Spotlight-Client: terraform-provider/<version>andSpotlight-Api-Version. GETrequests, and requests that carry anIdempotency-Key, are retried up to 3 times after a network error or a429,502,503or504response, waiting 500 milliseconds before the first retry and doubling each time.
Terraform versions
| Feature | Terraform |
|---|---|
import blocks with id | 1.5 or later |
removed blocks | 1.7 or later |
| Write-only attributes | 1.11 or later |
import blocks with identity | 1.12 or later |
List resources and terraform query | 1.14 or later |
Resources
| Resource | API kind | Import id |
|---|---|---|
spotlight_workspace | workspace | <slug> |
spotlight_team | team | <workspace id>/<key> |
spotlight_line | line | <workspace id>/<team key>/<key> |
spotlight_skill | skill | <workspace id>/<team key>/<key> |
spotlight_harness_profile | harness-profile | <workspace id>/<team key>/<key> |
spotlight_integration | integration | <workspace id>/<team key>/<integration> |
spotlight_hook | hook | <workspace id>/<team key>/<key> |
spotlight_secret | secret | <workspace id>/<name> |
spotlight_workspace_token_trust | workspace-token-trust | <workspace id>/<key> |
spotlight_runner_pool | runner-pool | <workspace id>/<key> |
spotlight_runner_trust | runner-trust | <workspace id>/<key> |
spotlight_workspace_runners | workspace-runners | <workspace id>/<workspace slug> |
There is no resource for workspace tokens.
spotlight_hook, its list resource, its write-only signing.secret_wo and
the plan-time checks of hook expressions require a provider release that
includes them.
Every resource has these read-only attributes: id, version and address,
as the common fields describe.
Every resource has a resource identity, { id = "<id>" }, which an import
block may name instead of the import id:
import {
to = spotlight_line.core_delivery
identity = {
id = "<line id>"
}
}spotlight_workspace is imported, never created. See
In Terraform.
Warnings the API returns become Terraform warnings on the attribute they name.
Data sources
| Data source | Arguments | Attributes |
|---|---|---|
spotlight_workspace | slug | id, name, address |
spotlight_team | workspace_id, key | id, name, address |
List resources
Each resource has a list resource of the same name, used in a list block in a
.tfquery.hcl file.
| List resource | Configuration |
|---|---|
spotlight_workspace | none |
spotlight_team, spotlight_secret, spotlight_workspace_token_trust, spotlight_runner_pool, spotlight_runner_trust, spotlight_workspace_runners | workspace_id |
spotlight_line, spotlight_skill, spotlight_harness_profile, spotlight_integration, spotlight_hook | workspace_id, and optionally team_id to list one team's |
list "spotlight_line" "core" {
provider = spotlight
config {
workspace_id = "<workspace id>"
team_id = "<team id>"
}
}terraform query -generate-config-out=generated.tf writes a resource and an
import block for each item. Prompts and skill files are written inline.
Replacement
Changing any of these attributes replaces the resource.
| Resource | Attributes |
|---|---|
spotlight_workspace | slug |
spotlight_team | workspace_id, key |
spotlight_line, spotlight_skill, spotlight_harness_profile, spotlight_hook | team_id, key |
spotlight_integration | team_id, definition.integration (the read-only source) |
spotlight_secret | workspace_id, name |
spotlight_workspace_token_trust, spotlight_runner_trust | workspace_id, key |
spotlight_runner_pool | workspace_id, key, and adding or removing provision |
spotlight_workspace_runners | workspace_id |
Write-only values
Write-only attributes are sent to Spotlight and never stored in the plan or the state. Each has a version attribute beside it; a change to the version sends the value again.
| Resource | Write-only attribute | Version attribute |
|---|---|---|
spotlight_secret | value_wo | value_wo_version |
spotlight_runner_pool | token | token_version |
spotlight_runner_pool | provision.secret | provision.secret_version |
spotlight_hook | signing.secret_wo | signing.secret_wo_version |
A pull pool created without token is issued one by Spotlight in the
Spotlight-Pool-Token response header. The provider does not keep it, and
warns.
Plan-time expression checks
During terraform plan, the provider sends each CEL expression in a
spotlight_integration definition and in a spotlight_hook (when and the
templated strings in steps) to POST /api/expressions/check. An expression
that does not check fails the plan, on the attribute that holds it. The token
needs the plan scope.
In HCL, an expression in an integration's definition or a hook's steps is
written $${{ ... }}, Terraform's escape for a literal ${{ ... }}. A hook's
when may be written bare, without ${{ }}.
See Expressions for what each position sees.