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

Destroy StackGen-Provisioned Infrastructure

The stackgen destroy command is used to tear down the infrastructure provisioned from exported appStack IaC configurations.

Usage

stackgen destroy [flags]
note

If you skip adding the --apply flag, you will only be able to preview changes and not execute them.

Flags

FlagDescription
--applyPreview and apply the infrastructure changes. This command does not require further approval.
--appstack-id stringThe ID of the appStack that needs to be provisioned. To get the appStack ID, run stackgen appstack show.
--backend-config stringArrayBackend configuration as a key=value pair or a path to an HCL file with key/value assignments. This flag can be specified multiple times.
--cloud-profile stringSpecify the credential profile to use for provisioning the infrastructure. This works only for AWS. For other clouds, make sure default credentials are set.
--env-profile stringEnvironment profile to use for provisioning or tearing down the infrastructure.
-h, --helpDisplays help information for the destroy command.
--var stringArraySpecify a value for one of the input variables. This flag can be specified multiple times.
--var-file stringSpecify the custom vars file path. By default, it uses the terraform.tfvars.json in the --work-dir.
--work-dir stringDirectory location of the IaC. If --appstack-id is provided, this will be used as the directory to store the state file.

Examples

Usage 1: Destroy Infrastructure with Apply Preview

stackgen destroy --apply --appstack-id 12345-uuid --work-dir ./iac-directory

The above command will:

  • Preview and apply the infrastructure changes.
  • Use the provided appStack ID (12345-uuid).
  • Use the specified working directory (./iac-directory) for storing the state file.

Usage 2: Destroy Infrastructure with Cloud Profile

stackgen destroy --appstack-id 12345-uuid --cloud-profile my-aws-profile --var-file ./custom-vars.tfvars.json

The above command will:

  • Use the provided appStack ID (12345-uuid).
  • Specify the cloud profile (my-aws-profile) for AWS credential usage.
  • Use the custom variables file (./custom-vars.tfvars.json).

Usage 3: Destroy Infrastructure with Backend Configuration

stackgen destroy --appstack-id 12345-uuid --backend-config 'bucket=my-bucket' --env-profile prod

The above command will:

  • Use the provided appStack ID (12345-uuid).
  • Set the backend configuration to use my-bucket.
  • Specify the environment profile (prod) for provisioning or tearing down the infrastructure.