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. This option does not require further approval to proceed with provisioning.
--appstack-id stringSpecifies the ID of the appStack to provision. Get the appStack ID by running stackgen appstack show.
--backend-config stringArrayAllows specifying backend configurations as key-value pairs or a path to an HCL file with the configuration. Multiple uses allowed. Example: --backend-config='bucket=my-bucket'.
--cloud-profile stringSpecifies the credential profile for provisioning. Works only for AWS. For other clouds, ensure default credentials are set.
--env-profile stringDefines the environment profile for provisioning or tearing down infrastructure.
--var stringArraySpecifies a value for one of the input variables. This flag can be used multiple times. Example: --var='region=us-west-1'.
--var-file stringSpecifies the custom variables file path. Default is terraform.tfvars.json in the --work-dir.
--work-dir stringSpecifies the directory for the IaC files. If --appstack-id is provided, it will be used to store the state file.

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.