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

AttributeTypeDefaultDescription
urlstringnoneThe 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.
tokenstringnoneSensitive. A stored workspace token. Without it, the SPOTLIGHT_API_TOKEN environment variable. Without either, and without a trust, the login for the address.
oidc.truststringnoneThe id of an OIDC trust to exchange through. Without it, the SPOTLIGHT_OIDC_TRUST environment variable.
oidc.tokenstringnoneSensitive. 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.audiencestringnoneThe 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.

CredentialSet byActs
A stored workspace tokentoken, else SPOTLIGHT_API_TOKENonly within its workspace, as its scopes allow
An OIDC trustoidc.trust, else SPOTLIGHT_OIDC_TRUSTonly within its workspace, as the trust's scopes allow
A loginspotlight loginas 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, in SPOTLIGHT_CONFIG_DIR, else $XDG_CONFIG_HOME/spotlight, else ~/.config/spotlight. It takes the entry for the address of url, else of SPOTLIGHT_URL: its scheme and host, and its port when that is not the default.

  • With no url and no SPOTLIGHT_URL, the provider uses the one login in the file and its address. With more than one login, configuration fails on url with there 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 403 to a login says so.

  • With no credential, configuration fails on token with No 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 with the login of <email> for <address> expired or was revoked; run spotlight login --url <address> to sign in again.

  • url and token must 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 reads ACTIONS_ID_TOKEN_REQUEST_URL and ACTIONS_ID_TOKEN_REQUEST_TOKEN to request the OIDC token.
  • Every request carries Spotlight-Client: terraform-provider/<version> and Spotlight-Api-Version.
  • In GitHub Actions, a line's create and update carry Spotlight-Source-Commit: <owner>/<name>@<sha>, from GITHUB_REPOSITORY and GITHUB_SHA, when GITHUB_SERVER_URL is empty or https://github.com. See Source commit.
  • GET requests, and requests that carry an Idempotency-Key, are retried up to 3 times after a network error or a 429, 502, 503 or 504 response, waiting 500 milliseconds before the first retry and doubling each time.

Terraform versions

FeatureTerraform
import blocks with id1.5 or later
removed blocks1.7 or later
Write-only attributes1.11 or later
import blocks with identity1.12 or later
List resources and terraform query1.14 or later

Resources

ResourceAPI kindImport id
spotlight_workspaceworkspace<slug>
spotlight_teamteam<workspace id>/<key>
spotlight_lineline<workspace id>/<team key>/<key>
spotlight_skillskill<workspace id>/<team key>/<key>
spotlight_harness_profileharness-profile<workspace id>/<team key>/<key>
spotlight_integrationintegration<workspace id>/<team key>/<integration>
spotlight_hookhook<workspace id>/<team key>/<key>
spotlight_secretsecret<workspace id>/<name>
spotlight_oidc_trustoidc-trust<workspace id>/<key>
spotlight_runner_poolrunner-pool<workspace id>/<key>
spotlight_egressegress<workspace id>/<key>
spotlight_runner_trustrunner-trust<workspace id>/<key>
spotlight_workspace_runnersworkspace-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 sourceArgumentsAttributes
spotlight_workspaceslugid, name, address
spotlight_teamworkspace_id, keyid, 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 resourceConfiguration
spotlight_workspacenone
spotlight_team, spotlight_secret, spotlight_oidc_trust, spotlight_runner_pool, spotlight_egress, spotlight_runner_trust, spotlight_workspace_runnersworkspace_id
spotlight_line, spotlight_skill, spotlight_harness_profile, spotlight_integration, spotlight_hookworkspace_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.

ResourceAttributes
spotlight_workspaceslug
spotlight_teamworkspace_id, key
spotlight_line, spotlight_skill, spotlight_harness_profile, spotlight_hookteam_id, key
spotlight_integrationteam_id, definition.integration (the read-only integration)
spotlight_secretworkspace_id, name
spotlight_oidc_trust, spotlight_runner_trust, spotlight_egressworkspace_id, key
spotlight_runner_poolworkspace_id, key, and adding or removing provision
spotlight_workspace_runnersworkspace_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.

ResourceWrite-only attributeVersion attribute
spotlight_secretvalue_wovalue_wo_version
spotlight_runner_pooltokentoken_version
spotlight_runner_poolprovision.secretprovision.secret_version
spotlight_egresstokentoken_version
spotlight_hooksigning.secret_wosigning.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.

On this page