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

Provision Infrastructure with StackGen

Prerequisites

You will need to install the following before you provision or deploy your appStacks:

The stackgen provision command provisions the infrastructure defined by exported appStack Infrastructure as Code (IaC) configurations. This command assumes that the required cloud credentials are already configured.

Usage

stackgen provision [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.
ⓘ Note: This command does not require further approval.
--appstack-id stringThe ID of the appStack that needs to be provisioned.
Run stackgen appstack show to get the appStack ID.
--backend-config stringArrayBackend configuration as a key-value pair or a path to an HCL file with key/value assignments.
For example,
--backend-config='bucket=my-bucket or
--backend-config=./backend.conf.
This 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, please make sure default credentials are set.
--env-profile stringEnvironment profile to use for provisioning or tearing down the infrastructure.
-h, --helpHelp for provision
--iac-tool stringSpecify the IaC tool to use for provisioning.
Supported values: terraform, tofu (default).
Check out the CLI Infra Provisioning with OpenTofu to learn more about this flag.
--var stringArraySpecify a value for one of the input variables. This can be specified multiple times.
For example, -var='region=us-west-1'
--var-file stringSpecify the custom vars file path. By default it uses the terraform.tfvars.json in the --work-dir
--work-dir stringDirectory path for the IaC files. If --appstack-id is provided, IaC will be cloned here.

Examples

Usage 1: Provision infrastructure with specific configuration

stackgen provision --appstack-id <appstack-id> --cloud-profile <aws-profile> --var 'region=us-west-2'

The above command will provision the infrastructure for the specified appstack-id using the given AWS profile and region.

Usage 2: Provision with backend configuration and environment profile

stackgen provision --appstack-id <appstack-id> --backend-config 'bucket=my-bucket' --env-profile dev

The above command will:

  • Provision the infrastructure for the specified appstack-id.
  • Use the provided backend configuration for the storage bucket.
  • Use the dev environment profile for provisioning.

Usage 3: Provision and apply changes automatically

stackgen provision --appstack-id <appstack-id> --apply --var 'region=us-west-1'

The above command will automatically apply infrastructure changes for the specified appstack-id without requiring further approval.