Provision Infrastructure with StackGen
Prerequisites
You will need to install the following before you provision or deploy your appStacks:
- terramate: Refer to the terramate documentation to install terramate.
- OpenTofu: Follow the steps to install OpenTofu.
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
Flag | Description |
---|---|
--apply | Preview and apply the infrastructure changes. ⓘ Note: This command does not require further approval. |
--appstack-id string | The ID of the appStack that needs to be provisioned. Run stackgen appstack show to get the appStack ID. |
--backend-config stringArray | Backend 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 string | Specify 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 string | Environment profile to use for provisioning or tearing down the infrastructure. |
-h , --help | Help for provision |
--iac-tool string | Specify 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 stringArray | Specify a value for one of the input variables. This can be specified multiple times. For example, -var='region=us-west-1' |
--var-file string | Specify the custom vars file path. By default it uses the terraform.tfvars.json in the --work-dir |
--work-dir string | Directory 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.