Skip to main content
⏳ Estimated read time: 3 min read

Usage

Usage

Command Groups

StackGen CLI commands are grouped by purpose, such as Infrastructure Lifecycle Management, appStack Management, and authentication.

We've listed the grouping below:

ILM Commands

CommandDescription
destroyTeardown your infrastructure
driftDetect and manage infrastructure drift
provisionInit and plan appStack IaC by default; add --apply to apply changes

appStack Management Commands

CommandDescription
appstackManage appStacks for complex codegen
generateGenerate IaC files and export to a directory
importImport infrastructure to StackGen (Terraform state)

Authentication Commands

CommandDescription
loginAuthenticate the CLI (configure is an alias)
logoutClear token and project from local config
whoamiShow authenticated account and project

Other Commands

CommandDescription
policiesList, inspect, and upload organization policies
projectRetrieve and manage projects within StackGen
resourceResource management commands
runExecute any tofu or terraform command
stateManage OpenTofu or Terraform state
uploadUpload custom modules and security rules

Additional Commands

CommandDescription
completionGenerate the autocompletion script for the specified shell
helpHelp about any command
**mcpStart the MCP stdio server for LLM integrations
versionPrints the version of the stackgen cli

Standalone CLIs

These tools ship separately from the stackgen binary:

CLIDescription
terraform-importerImport existing Terraform configuration into StackGen
cloud2codeGenerate Terraform state files from cloud resources

Quick Commands

Click to view

Help on Usage

stackgen help

Enter the CLI Container

docker run -it --rm -p 50525:50525 -v ~/.stackgen:/home/stackgen/.stackgen ghcr.io/stackgenhq/stackgen:latest
note

This will switch the terminal prompt to the StackGen CLI container where StackGen can be run.

Login or Configure Authentication:

stackgen login

You can also run stackgen configure (alias for stackgen login).

note

This will present you with a clickable link to copy and paste into your browser on your main machine to complete login.

Connect to a Repository

export APPCD_GIT_AUTH_TOKEN={token with readonly access to desired repositories}

Exporting a valid token allows stackgen appStack create to display your available repositories and branches for easier selection.

Create an appStack

stackgen appstack create

Create appStack Version

stackgen appstack create-version <name of appStack>

See create-version for flags and examples.

List appStacks

stackgen appstack show

Download or Generate IaC Files for an appStack

stackgen appstack download-iac --appstack <appStack-id-or-name> --destination <path/to/file.zip>
note

By default, the docker run command above creates a volume in /app/.stackgen in the container, so any files written there will be synced to ~/.stackgen on the host machine.