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"
version = "0.1.0-rc.4"
}
}
}The provider is a release candidate. Terraform selects a release candidate
only for an exact version, so version names one.
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. Without either, and without a token or trust, the address of the one login that spotlight login keeps. |
token | string | none | Sensitive. A stored workspace token. Without it, the SPOTLIGHT_API_TOKEN environment variable. Without either, and without a trust, the login for the address. |
oidc.trust | string | none | The id of an OIDC 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. |
Credentials
The provider uses a token or a trust when one is set. When neither is set, it
uses the login that spotlight login keeps.
| Credential | Set by | Acts |
|---|---|---|
| A stored workspace token | token, else SPOTLIGHT_API_TOKEN | only within its workspace, as its scopes allow |
| An OIDC trust | oidc.trust, else SPOTLIGHT_OIDC_TRUST | only within its workspace, as the trust's scopes allow |
| A login | spotlight login | as the person who logged in, with their role in each workspace |
-
A token and a trust are exclusive. With both, configuration fails with
Both a token and an OIDC trust. -
The provider reads the login from
credentials.json, inSPOTLIGHT_CONFIG_DIR, else$XDG_CONFIG_HOME/spotlight, else~/.config/spotlight. It takes the entry for the address ofurl, else ofSPOTLIGHT_URL: its scheme and host, and its port when that is not the default. -
With no
urland noSPOTLIGHT_URL, the provider uses the one login in the file and its address. With more than one login, configuration fails onurlwiththere are logins for <addresses>; set url, or SPOTLIGHT_URL, to the one to use. -
A credentials file that is not valid JSON fails configuration with
Could not use the Spotlight login. The provider skips an entry that has no token. -
A login acts with the person's role in the workspace. Runner pools, secrets and trusts need a workspace admin. A
403to a login says so. -
With no credential, configuration fails on
tokenwithNo API token:The provider has no API token, OIDC trust or login for this Spotlight. On your machine, run spotlight login. Or set token, or SPOTLIGHT_API_TOKEN, to a Spotlight API token. In CI, set oidc.trust, or SPOTLIGHT_OIDC_TRUST, to the id of an OIDC trust. -
When Spotlight answers a login with
401, the request fails withthe login of <email> for <address> expired or was revoked; run spotlight login --url <address> to sign in again. -
urlandtokenmust be known when Terraform plans.
Requests
- A token issued by a trust is renewed one minute before it expires, and
exchanged again when Spotlight answers 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. - In GitHub Actions, a line's create and update carry
Spotlight-Source-Commit: <owner>/<name>@<sha>, fromGITHUB_REPOSITORYandGITHUB_SHA, whenGITHUB_SERVER_URLis empty orhttps://github.com. See Source commit. 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_oidc_trust | oidc-trust | <workspace id>/<key> |
spotlight_runner_pool | runner-pool | <workspace id>/<key> |
spotlight_egress | egress | <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_oidc_trust, spotlight_runner_pool, spotlight_egress, 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 integration) |
spotlight_secret | workspace_id, name |
spotlight_oidc_trust, spotlight_runner_trust, spotlight_egress | 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_egress | token | token_version |
spotlight_hook | signing.secret_wo | signing.secret_wo_version |
A spotlight_secret takes value_wo only together with value_wo_version.
Without both, a person sets its value outside Terraform. See
Value.
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. The same applies to an egress created without token, in the
Spotlight-Egress-Token header.
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/v1/expressions/check. An expression
that does not check fails the plan, on the attribute that contains 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 the variables each position can read.