Skip to content

feat: add stack state pull command#410

Merged
michalrom089 merged 2 commits intomainfrom
feat/stack-state-pull
Apr 7, 2026
Merged

feat: add stack state pull command#410
michalrom089 merged 2 commits intomainfrom
feat/stack-state-pull

Conversation

@michalrom089
Copy link
Copy Markdown
Contributor

@michalrom089 michalrom089 commented Apr 7, 2026

Description

Add spacectl stack state pull command that downloads the current Terraform/OpenTofu state file for a stack. Calls the stateDownloadUrl GraphQL mutation to get a presigned S3 URL, then downloads and writes the state to stdout or a file.

Type of Change

  • New feature

Changes Made

  • internal/cmd/stack/state.go — new statePull() action and StateDownloadUrlInput type
  • internal/cmd/stack/stack.go — registered state subcommand group with pull subcommand

Testing

  • I have tested these changes locally
  • I have added/updated tests as needed
  • All existing tests pass

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • My changes generate no new warnings

Related Issues

Related to ClickUp 869ctjahm
Featurebase: Programmatic access to Spacelift managed state

@michalrom089 michalrom089 force-pushed the feat/stack-state-pull branch 3 times, most recently from 62ab739 to 076d957 Compare April 7, 2026 10:35
@michalrom089 michalrom089 marked this pull request as ready for review April 7, 2026 10:35
@michalrom089 michalrom089 requested a review from a team as a code owner April 7, 2026 10:35
@michalrom089 michalrom089 force-pushed the feat/stack-state-pull branch 3 times, most recently from 5cfd1a0 to 11a11cb Compare April 7, 2026 11:01
Downloads the current Terraform/OpenTofu state file for a stack
via the stateDownloadUrl GraphQL mutation and presigned S3 URL.

Usage: spacectl stack state pull [--id <stack-id>] [--output <file>]
@michalrom089 michalrom089 force-pushed the feat/stack-state-pull branch from 11a11cb to 9418300 Compare April 7, 2026 11:10
@eliecharra eliecharra self-requested a review April 7, 2026 11:54
Copy link
Copy Markdown
Member

@eliecharra eliecharra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great 👍🏻 Just left a minor comment about simplification of the output streaming code, not a blocker at all.

Comment thread internal/cmd/stack/state.go Outdated
Use stdout as default writer, single io.Copy path.
@michalrom089 michalrom089 merged commit 321a8fc into main Apr 7, 2026
7 checks passed
@michalrom089 michalrom089 deleted the feat/stack-state-pull branch April 7, 2026 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants