Skip to main content

Terraform resource for managing Tasks on a stack

I would like to run a Task against a stack as a terraform resource. Sorta similar to how spacelift_run works. The spacelift_scheduled_task resource is not sufficient, because I want to run it immediately and wait for completion.

Proposed resource model:

resource "spacelift_stack_task" "this" {
  command  = string
  init     = optional(bool, true)
  stack_id = string
  wait     = optional(bool, true)
}

I created a feature request on GitHub also, for the spacelift terraform provider, https://github.com/spacelift-io/terraform-provider-spacelift/issues/573

Workaround
Not really, no.
Problem
See the description above.
Status: ✅ Completed3 comments

Log in to comment and vote

Comments3

  • Yellow Mirror

    •

    Oct 18, 2024

    Some fairly typical, workflow-y things that need doing via tasks, since they aren’t currently part of any Spacelift run workflow:

    • Generate/retrieve .terraform.lock.hcl for committing back to repo

    • Destroy stack resources in a way that preserves logs and run visibility

    • Remove resources from state that are blocked from destroy (marked with lifecycle prevent_destroy = true)

  • Yellow Mirror

    •

    Oct 18, 2024

    Why do tasks exist at all? What use cases were used to support that requirement/work? All of those are use cases for this as well. I just want to execute tasks via terraform, rather than manually or via the API.

  • Natalia Gazda

    Team•

    Oct 18, 2024

    Hey @Loren Gordon, could you please provide a bit more context - some use-cases maybe? Thank you!