Skip to main content

Overview

The alasti-company/shipd provider manages shipd resources through the control-plane API. For installation and a complete configuration, see Manage projects and environments with Terraform. Install the published alasti-company/shipd provider with terraform init. The v0.1 release manages projects and environments. Webhook resources require a provider release that includes them and API support for snapshotWebhook/createConfig and eventWebhook/createConfig. Credential resources require a provider release that includes them and a shipd API with credential registration support.

Provider configuration

provider.tf
Prefer SHIPD_API_KEY over putting credentials in configuration. SDK keys cannot authenticate the provider. Creating projects requires an organization-wide service account token. Management API keys work within their bindings but cannot create projects. Project-bound service account tokens can manage environments in that project; environment-bound credentials cannot create environments. Read-only consumers need the corresponding project:read and environment:read scopes. See token scopes and binding.

Resources

shipd_project

Creates a project in the credential’s organization.

shipd_environment

Creates an environment within a project.

shipd_snapshot_webhook

Sends snapshot.published notifications to a Convex HTTP action. Each environment supports one destination. Use a service account token with environment:read and snapshot_webhook:read, plus snapshot_webhook:manage for writes. See Connect Convex for receiver setup.

shipd_event_webhook

Sends customer events to an HTTPS endpoint. The event type set filters which events are delivered. Use a service account token with event_webhook:read, plus event_webhook:manage for writes. The organization must have customer event webhooks enabled to create endpoints. See Receive customer events for receiver setup.

Webhook credentials and delivery

Terraform manages webhook configuration. Set up signing secrets, test deliveries, view delivery history, and redeliver events in shipd.
  • Signing secrets. shipd generates a secret on creation. Terraform receives and stores only configuration. For a new webhook, set enabled = false, use Rotate secret for a Convex destination or Rotate signing secret for an event endpoint, and save the returned secret in the receiver’s secret manager. Then set enabled = true and apply. Existing webhooks keep their signing secret when imported or updated. Replacing a webhook creates a new secret.
  • Destination URLs. Terraform marks URLs sensitive and stores each complete URL in plans and state. Use URLs without credentials, including credentials in paths or query strings. Protect plan and state files if you import an existing URL that contains a credential.
  • Drift and deletion. Refresh reads the current configuration, including enabled state and event subscriptions. Terraform plans to recreate webhooks deleted outside Terraform. Destroy deletes the webhook. Deleting an event endpoint also cancels its pending deliveries.
  • Interrupted creation. The provider reuses the request’s idempotency key during retries. If an apply stops before it records the webhook in state, check the environment in shipd and import any webhook the apply created.

Data sources

Read existing objects without taking ownership of their lifecycle:
data.tf
Both data sources accept exactly one of id or slug. The environment data source also requires project_id.

Import existing resources

Declare the matching resource blocks first, then import:
Set type and is_production explicitly when importing an environment whose values differ from the defaults (development and false). Set enabled = false in configuration when importing a disabled webhook. Review the plan before applying changes.

Lifecycle and drift

  • Ownership. Terraform manages only resources declared in configuration. Data sources leave ownership with shipd.
  • Destroy. Destroy archives projects and environments. Recovery and slug reservation last seven days. Creating again does not automatically restore or adopt it: restore through the dashboard and import, choose another slug, or wait for the reservation to expire. Archiving a project also makes its child resources inaccessible.
  • Protection. Use lifecycle { prevent_destroy = true } for important resources. Approval policies may block archive or production changes; the provider returns the API error and retains state. It does not approve requests.
  • Production changes. To move production to another environment, first set is_production = false on the current one and apply. Then set is_production = true on the replacement and apply again. Implicit demotion is rejected, including during concurrent writes. Setting type = "production" alone does not designate production.
  • Drift. External changes appear in the next plan. Project and environment updates use the refreshed API version. A concurrent project or environment change returns a conflict; run a fresh plan before retrying.
  • Reads. Objects that no longer exist are removed from Terraform state. Authorization and transport failures return errors instead of treating objects as missing.
  • Interrupted creation. Retries reuse an idempotency key within one operation. If creation commits but the process stops or response retries are exhausted, inspect shipd and import the existing ID before retrying.
Environment updates require API support for environment/updateWithoutHandoff. Older servers reject the operation instead of falling back to an update that could demote another environment.

Manage credentials from CI

Use Terraform 1.11 or later for shipd_sdk_key and shipd_service_account_token. Use a dashboard-created service account token as SHIPD_API_KEY and keep that bootstrap account and token outside the configuration they authenticate. If Terraform also manages the workload account, grant the separate service account administration scopes required by shipd_service_account. Set scopes explicitly. SDK keys accept snapshot:read, events:write, and stream:connect. Server SDK keys can also receive identity:read. Service account token scopes use the resource-to-verbs map. For example, a token that reads projects needs only project = ["read"]. Use RFC3339 timestamps for expiry.

Generate and deliver a secret

Generate a lowercase UUIDv4 for the credential’s id. Use the prefix shipd_sdk_client_, shipd_sdk_server_, or shipd_sa_, followed by 32 random bytes encoded as unpadded base64url, a dot, and the first 32 lowercase hex characters of the organization ID’s SHA-256 digest.
generate_credential.py
Save the generated secret in a versioned secret store before applying. Set secret_version to the nonsecret version identifier and use that same version for every attempt. Pass the secret value to Terraform through a sensitive, ephemeral variable and the secret_wo argument. After registration succeeds, configure the consumer to read the same secret-store version. On a self-hosted installation, deploy the matching edge and WebSocket gateway builds before using registered SDK keys.
sdk-key.tf
Use the same write-only pattern for shipd_service_account_token. Set service_account_id and expires_at, supply a scope map, and omit key_type. CI can load the secret from its store into TF_VAR_runtime_sdk_key with shell command tracing disabled. The secret is required when creating or replacing a credential. Refresh and destroy can run with the ephemeral variable set to null. Terraform state and saved plans. These resources persist IDs, names, bindings, scopes, expiry, the secret-store version identifier, key type for SDK keys, and revocation status. They store no plaintext, lookup prefixes, or hashes, and expose no secret output. Terraform keeps the version identifier locally. The provider sends the prefix and SHA-256 digest to shipd for lookup and verification. SHIPD_API_KEY keeps the bootstrap token outside Terraform configuration. Terraform’s sensitive marking only masks display output. Use an ephemeral input and write-only argument to keep a credential out of plans and state. An ordinary sensitive variable, output, or secret store resource elsewhere in your configuration may still persist its value.

Recover an interrupted apply

If a request times out or an apply ends before writing state, rerun with the original UUID, original metadata, and same secret-store version. The API compares the UUID, lookup prefix, hash, and credential metadata before acknowledging the existing record. For SDK keys, it also retries edge publication. Concurrent or repeated registrations produce one credential and one creation audit event. Changing the secret or metadata under the same ID produces a conflict. The provider never replays a response containing a secret. If the original secret-store version is gone, wait for any in-flight apply to settle, then revoke the old credential by UUID in shipd before registering a new UUID and secret. If the interrupted run never wrote state, use the dashboard or call sdkKey/revoke with keyId and orgId, or serviceAccount/revokeToken with tokenId, serviceAccountId, and orgId. You can apply the exact original configuration to recover ownership of a live Terraform registration. Importing credentials created through other workflows with terraform import is unsupported. Existing service account identities can still be imported.

Rotate, retire, and replace

  1. Create a second resource with a fresh UUID and secret. Apply while the old resource stays in configuration.
  2. Switch the consumer to the new secret-store version and verify an authenticated request.
  3. Remove the old resource and apply to revoke it, then retire its secret-store version.
Both credentials remain usable between the two applies, up to either credential’s expiry. Choose and enforce the overlap in CI. shipd applies no automatic grace period. CI can revoke an SDK key by ID after its project is archived. SDK key revocation takes effect as it propagates to the edge. Open WebSocket connections revalidate at least every 60 seconds. Service account tokens fail control-plane authentication when revoked, expired, or attached to a disabled account. See credential revocation behavior. Changing the secret version or another immutable property requires a fresh UUID and secret. Keep the secret-store version immutable because Terraform cannot diff the write-only value. Replacing one resource address uses Terraform’s default destroy-first ordering and can interrupt workloads. Use the two-resource sequence for overlap. Avoid forcing replacement with -replace on the same UUID, since revoked registrations cannot be reused. Refresh shows revoked = true for a credential revoked outside Terraform. Expiry and external revocation require an explicit rotation.