Overview
Use the shipd Terraform provider to create and manage projects and environments, detect drift, or look up existing objects. Continue to manage flag definitions with config as code. See the Terraform provider changelog for the resources each release supports.This guide pins the v0.1 provider for projects and environments. For the
credential resources available in later builds, see Manage credentials from CI.
Prerequisites
- Terraform 1.11 or later. CI covers Terraform 1.11.4 and 1.17.1; OpenTofu compatibility is not yet established.
- A shipd organization and a service account token. To create projects, use an organization-wide token with no project or environment binding.
Configure credentials
Load your service account token from your secret store into the shell where you will run Terraform:Create a project and environment
Createmain.tf in your configuration directory. Terraform installs the published alasti-company/shipd provider from the Terraform Registry:
main.tf
.terraform.lock.hcl to keep provider versions consistent across your team and CI. If you previously used a local build, remove its dev_overrides entry from your Terraform CLI configuration before initializing so Terraform uses the published provider.
For existing projects or environments, import their IDs before applying, or use data sources to read them without managing their lifecycle.
Report runs from CI
In Settings → Service accounts, create a service account token with theterraform: report scope. Bind it to the project and environment your CI job targets and save it as SHIPD_TERRAFORM_REPORT_TOKEN in CI. Set SHIPD_PROJECT_ID, SHIPD_ENVIRONMENT_ID, and CI_RUN_URL for the job. The project and environment IDs appear in the example configuration under Project settings → Integrations → Terraform.
Run this script directly after your CI job finishes a plan or apply. Pass the operation, its exit code, and the ISO 8601 completion timestamp.
report-terraform-run.sh
terraform plan -detailed-exitcode when reporting plans. Exit code 0 means no changes, 2 means changes, and 1 means the plan failed. Terraform plan command reference
apply, the apply exit code, and its completion timestamp. Keep the original completedAt if you retry a report. The endpoint returns data.recorded: false when it already has a report for that operation with an equal or newer completion timestamp.
The Terraform runs panel shows the latest completed plan and apply for the selected environment, each with its CI run link. Results are marked Stale after seven days. Apply status describes the reported run at completion.
Next
- Terraform provider reference for configuration, resources, data sources, and lifecycle behavior.
- Define flags in code after provisioning your project and environment.
- Service account tokens for scopes and binding rules.