Flags & Array Flags

Flags and Array Flags allow you to customise the command-line arguments passed to engine commands (init, plan, apply, destroy, output). They are available for both Terraform and Pulumi engines, and can be set at the Namespace level (applying to all Modules in the Namespace) or at the Module level.

  • A Flag is a single-value argument (e.g. --lock-timeout=10m)
  • An Array Flag is an argument that can appear multiple times (e.g. -target=..., -backend-config=...)

Terraform Flags

You can see the full specifications here:

Pulumi Flags

Pulumi flags are only available when the Pulumi preview feature has been enabled for your organization. See Engine for details.

You can see the full specifications here:

Example: Backend Configuration

Backend configuration for Terraform / OpenTofu is handled via Terraform Array Flags with flag = "BackendConfig" and task = "Init".

For example, to initialize Terraform with:

terraform init \
  -backend-config="bucket=my-terraform-state-bucket" \
  -backend-config="key=state/myproject.tfstate" \
  -backend-config="region=us-east-1"

Create three Terraform Array Flag resources:

resource "snapcd_module_terraform_array_flag" "backend_bucket" {
  module_id = snapcd_module.mymodule.id
  task      = "Init"
  flag      = "BackendConfig"
  value     = "bucket=my-terraform-state-bucket"
}

resource "snapcd_module_terraform_array_flag" "backend_key" {
  module_id = snapcd_module.mymodule.id
  task      = "Init"
  flag      = "BackendConfig"
  value     = "key=state/myproject.tfstate"
}

resource "snapcd_module_terraform_array_flag" "backend_region" {
  module_id = snapcd_module.mymodule.id
  task      = "Init"
  flag      = "BackendConfig"
  value     = "region=us-east-1"
}

Example: Targeting Specific Resources

Use the Target array flag to limit operations to specific resources:

resource "snapcd_module_terraform_array_flag" "target" {
  module_id = snapcd_module.mymodule.id
  task      = "Apply"
  flag      = "Target"
  value     = "azurerm_resource_group.example"
}

Migrating from Backend Configs

The snapcd_module_backend_config and snapcd_namespace_backend_config resources are deprecated. Replace them with snapcd_module_terraform_array_flag / snapcd_namespace_terraform_array_flag using flag = "BackendConfig" and task = "Init".

Last updated on