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, and default values.

Precedence is always Organization over Tenant (if a preference is set at both levels, the organization value is used).

KeyDescriptionDefault Value
topology.iac.export.
terraform.exportDirectory
The directory where the Terraform files will be exportedterraform
topology.iac.export.
helm.exportDirectory
The directory where the Helm files will be exportedhelm
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.
false
topology.iac.export.
blockExport
OnComplianceCheckFailure
Flag to block IaC export if compliance check failstrue
topology.iac.export.
defaultBackendType
The default backend type for IaC exported from Topologynone

Allow Iac Export When Compliance Checks Fail

warning

Disabling export blocking allows workflows to proceed despite compliance violations. Use this only when your team accepts that risk or while governance policies are being updated.

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

To allow export when compliance checks fail, set the preference to false:

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>

Flags (get)

FlagDescription
-h, --helpHelp for preference get.
--preference-keysComma-separated list of preference keys to retrieve.
--include-all-valuesInclude all values for the selected preference key.

Example:

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

Example (include all values for the key):

stackgen preference get --preference-keys topology.iac.export.terraform.exportDirectory --include-all-values

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.