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

Manage StackGen Preferences

The stackgen preference command allows you to manage StackGen preferences, including retrieving preference values, listing available preference keys, and setting preference values for your organization or project.

Usage

stackgen preference [command]

Available Commands

CommandDescription
keysList available preference keys within StackGen
getRetrieve preference values
setSet preference values
note

For get and set, the commands run for a specific environment. So let's say if you want to set preferences for your test environment, make sure you have configured the relevant environment.

Flags

FlagDescription
-h, --helpDisplays help information for the preference command.

Global Flags

Refer to the Global flags section.

Keys

Click to view

This command lists all available preference keys within StackGen. This is typically the first step to discover the preferences you can configure.

stackgen preference keys

This command displays a table showing all available preference keys, their descriptions, default values, and precedence order.

KeyDescriptionDefault ValuePrecedence
topology.iac.export.
terraform.exportDirectory
The directory where the Terraform files will be exportedterraformOrganization > Tenant
topology.iac.export.
helm.exportDirectory
The directory where the Helm files will be exportedhelmOrganization > Tenant
topology.iac.export.terraform.
exportRootProviderFiles
IfOnlyCustomResourcesUsed
Flag to export root provider files provider.tf and variables.tf if only custom resources are used.
  • When set to true, root provider files are exported.
  • When set to false, root provider files are not exported when only custom resources are used.
falseOrganization > Tenant
topology.iac.export.
blockExport
OnComplianceCheckFailure
Flag to block IaC export if compliance check failstrueOrganization > Tenant
topology.iac.export.
defaultBackendType
The default backend type for IaC exported from TopologynoneOrganization > Tenant
Precedence

Preferences follow a precedence order where Organization level preferences take precedence over Tenant level preferences. This means that if a preference is set at both levels, the Organization-level value will be used.

Allow Iac Export When Compliance Checks Fail

warning

Disabling export blocking allows workflows to proceed despite compliance violations. This should be used only when violations are known false positives or when governance policies are being refined.

By default, StackGen blocks Infrastructure as Code (IaC) export if any compliance or governance policy fails.

In some scenarios, compliance checks may produce false positives, for example, when a security group appears to allow public access but is actually restricted to private subnets or VPCs. This can prevent users from exporting IaC even when the infrastructure is correctly secured.

To avoid blocking workflows in such cases, you can disable export blocking while still retaining visibility into policy violations.

Example use case: A security group allows inbound traffic on a specific port (for example, 443, 5432, 6379) but is attached only to private subnets without internet exposure. If the compliance policy does not evaluate subnet or VPC context, it may incorrectly flag this as public access.

In such cases, disabling export blocking allows teams to continue IaC export while governance policies are updated or refined.

stackgen preference set \
--preference-key topology.iac.export.blockExportOnComplianceCheckFailure \
--owner-type Organization \
--value false

Get

Click to view

This command lets you retrieve current preference values for your environment.

stackgen preference get

To retrieve the current preference values for a specific key, run the command:

stackgen preference get --preference-keys<preference-key>

Example:

stackgen preference get --preference-keys topology.iac.export.terraform.exportDirectory

This command retrieves the current value of the Terraform export directory preference.

Set

Click to view

This command lets you set preference values for your organization or project.

stackgen preference set [flags]

Flags

FlagDescription
-h, --helpDisplays help information for the set command
--owner-type stringThe owner type to set (e.g., Organization, Project)
--preference-key stringThe preference key to set
--value stringThe value to set for the preference key

Examples

  • Set a preference for export directory

    stackgen preference set --preference-key topology.iac.export.terraform.exportDirectory --owner-type Organization --value tf

    This command sets the Terraform export directory preference to tf at the organization level.

  • Set provider file export preference

    stackgen preference set --preference-key topology.iac.export.terraform.exportRootProviderFilesIfOnlyCustomResourcesUsed --owner-type Organization --value false --project <projectid>

    This command disables the default provider file creation when only custom resources are used, at the organization level for a specific project.