Skip to content

spacelift_run: Support custom runtime configuration (environment variables and TF var overrides) #775

@Azmah-Bad

Description

@Azmah-Bad

Summary

The spacelift_run resource currently supports triggering runs on a stack, but has no way to pass custom runtime configuration, environment variables or Terraform variable overrides scoped to a single run.

This capability already exists in the Spacelift UI ("Trigger with custom runtime config") and the GraphQL API, but the Terraform provider doesn't expose it.

Use Case

When programmatically triggering runs, it's common to need per-run configuration that differs from the stack's default. For example:

  • Passing a one-time variable override to control behavior for a specific run
  • Setting an environment variable that should not persist on the stack
  • Triggering a targeted plan/apply with runtime-specific parameters

Proposed Change

Add an optional block to spacelift_run for runtime configuration:

resource "spacelift_run" "example" {
  stack_id = spacelift_stack.this.id

  runtime_config {
    environment_variable {
      key   = "TARGET_RESOURCE"
      value = "aws_instance.example"
    }

    terraform_variable {
      key   = "enable_migration"
      value = "true"
    }
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions