agentsclimarketplace

Spacelift terraform

Skill way-platform/skills/spacelift-terraform

Re-usable skills for agents at Way

Install
npx -y skills add way-platform/skills --skill spacelift-terraform

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 3 stars3 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its author says it does

Copied from the file, not written here

Spacelift for Terraform GitOps. Use when working with Spacelift stacks, runs, policies, contexts, worker pools, drift detection, or spacectl CLI.

SKILL.md

8.5 KB, as published. Nobody here has run it

Spacelift

Spacelift orchestrates Terraform via GitOps: GitHub pushes trigger runs, policies govern behavior, contexts inject config, workers execute runs.

  • API: https://<account>.app.spacelift.io/graphql
  • Terraform provider: spacelift-io/spacelift
  • spacectl: brew install spacelift-io/spacelift/spacectl

Core Concepts

ConceptDescription
StackTerraform project unit: repo + branch + settings + state
RunExecution of terraform plan (proposed) or plan+apply (tracked)
PolicyOPA Rego rule set governing stack behavior (9 types)
ContextReusable bundle of env vars + mounted files + hooks
Worker PoolSet of runners executing runs (public Spacelift-hosted or private)
SpaceOrganizational boundary for access control and resource scoping

GitOps Workflow

feature branch push
  → push policy → propose
  → proposed run: terraform plan
  → commit status reported to PR

PR merged to tracked branch (e.g., main)
  → push policy → track
  → tracked run: terraform plan
  → if autodeploy: auto-apply
  → else: unconfirmed state → human confirms → apply

Run States

StateMeaning
QUEUEDWaiting for worker; approval policies evaluated here
INITIALIZINGWorker starting, downloading source
PLANNINGterraform plan running
UNCONFIRMEDPlan done, awaiting human confirm (or autodeploy blocked)
CONFIRMEDHuman confirmed, apply will start
APPLYINGterraform apply running
FINISHEDCompleted successfully
FAILEDRun failed at some phase
DISCARDEDManually abandoned

spacectl Quick Reference

Auth (CI/Agent — non-interactive)

export SPACELIFT_API_KEY_ENDPOINT=https://myorg.app.spacelift.io
export SPACELIFT_API_KEY_ID=$SECRET_KEY_ID
export SPACELIFT_API_KEY_SECRET=$SECRET_KEY_SECRET

GitHub Actions

- uses: spacelift-io/setup-spacectl@main
- run: spacectl stack deploy --id my-stack --auto-confirm --tail
  env:
    SPACELIFT_API_KEY_ENDPOINT: https://myorg.app.spacelift.io
    SPACELIFT_API_KEY_ID: ${{ secrets.SPACELIFT_API_KEY_ID }}
    SPACELIFT_API_KEY_SECRET: ${{ secrets.SPACELIFT_API_KEY_SECRET }}

Key Commands

spacectl stack list
spacectl stack deploy --id <stack> --auto-confirm --tail
spacectl stack task --id <stack> --tail 'terraform output -json'
spacectl run list --stack <stack>
spacectl run logs --stack <stack> --run <run-id>
spacectl run confirm --stack <stack> --run <run-id>
spacectl workerpool list
spacectl profile export-token          # get bearer token for API calls

Stack Settings Quick Reference

FieldKey Values
BranchTracked branch — pushes here trigger tracked runs
Project rootSubdirectory for Terraform root (monorepo)
Project globsSparse checkout paths (requires git checkout mode)
Autodeploytrue = auto-apply on clean plan
Autoretrytrue = retry proposed runs when state changes (private worker only)
Worker poolAssign private pool; required for drift detection
Runner imageCustom Docker image (default: public.ecr.aws/spacelift/runner-terraform:latest)
LabelsUsed by policies for auto-attach and filtering
Deletion protectionPrevent accidental stack deletion

Policy Types Quick Reference

TypeFires whenKey outputs
PushGit push or PR eventtrack, propose, ignore, cancel
PlanAfter terraform plandeny (fail), warn (require review)
TriggerTracked run reaches terminal statetrigger (stack IDs to cascade)
ApprovalRun enters queued/unconfirmedapprove, reject
LoginUser login attemptallow, deny, admin
Stack AccessStack access checkread, write, admin, deny
NotificationAny run state changenotification targets
TaskBefore task runsallow, deny
Run InitBefore run starts (deprecated)allow, deny

All policies use Rego v1 (package spacelift). Auto-attach via label autoattach:<label>.

Most Common Patterns

# Push: standard GitOps
track if input.push.branch == input.stack.branch
propose if not is_null(input.pull_request)
ignore if { not track; not propose }

# Plan: block deletions
deny contains sprintf("Deletion not allowed: %s", [c.entity.address]) if {
  some c in input.spacelift.run.changes; c.action == "deleted"
}

# Plan: manual review for drift
warn contains "Drift reconciliation requires manual approval" if {
  input.spacelift.run.drift_detection
}

# Approval: require 1 reviewer
approve if count(input.reviews.current.approvals) >= 1

Reference Files

FileRead when
references/github-terraform-workflow.mdSetting up GitHub App, branch tracking, PR status checks, push policy patterns, monorepo sparse checkout
references/stack-configuration.mdStack creation fields, VCS settings, Terraform settings, hooks, scheduling, stack dependencies
references/policies.mdAll 9 policy types with full input schemas, Rego v1 examples, workbench testing
references/spacectl.mdCLI installation, auth methods, stack/run/worker commands, CI agent patterns, GraphQL API
references/contexts-and-config.mdContext creation, auto-attach labels, priority/conflict resolution, .spacelift/config.yml, env var precedence
references/worker-pools.mdPrivate worker setup (CSR → pool → launch), config vars, network requirements, sizing
references/drift-detection.mdScheduling, reconciliation, plan/trigger policy integration, drift run limits
references/gcp-integration.mdSetting up GCP OIDC (WIF), native GCP integration, credential config JSON, Terraform provider auth, hierarchical space access, direct resource access
references/terraform-provider.mdTerraform provider config, resource+data source inventory, HCL schemas for all core resources, AWS integration setup, import IDs

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.