Skip to content
GantryCD Provider

gantrycd_stack_contexts (Resource)

The ordered list of contexts a stack references. Authoritative over the whole list; order decides precedence (later wins, stack vars win over all).

Example Usage

resource "gantrycd_context" "shared" {
  name = "shared-defaults"

  variable {
    key   = "LOG_FORMAT"
    value = "json"
  }
}

resource "gantrycd_context" "payments" {
  name = "payments-overrides"

  variable {
    key   = "LOG_FORMAT"
    value = "text"
  }
}

resource "gantrycd_stack" "payments" {
  name              = "payments-production"
  repository_url    = "https://github.com/example/infrastructure"
  working_directory = "/payments"
  branch            = "main"
  opentofu_version  = "1.11.0"
}

# Ordered: a later context overrides an earlier one on a conflicting key, and
# the stack's own variables override all of them. List the lowest-precedence
# context first.
resource "gantrycd_stack_contexts" "payments" {
  stack_id    = gantrycd_stack.payments.id
  context_ids = [gantrycd_context.shared.id, gantrycd_context.payments.id]
}

Schema

Required

  • context_ids (List of String) Ordered context ids the stack references. Earlier entries are overridden by later ones on conflicting keys.
  • stack_id (String) Stack whose context list this resource manages.

Read-Only

  • id (String) Equals stack_id. Used as the Terraform import id.
  • identity_realm (String) Identity realm inherited from the configured provider.

Import

Import is supported using the following syntax:

The terraform import command can be used, for example:

# Import by stack id.
terraform import gantrycd_stack_contexts.payments stk_01HXXXXXXXXXXXXXXXXXXXXXXX