Ability to "namespace" Context attachments to avoid variable name clashing

We’d like to request the ability to optionally specify a namespace prefix when attaching a Context to a Stack. The goal is to avoid variable collisions when multiple Contexts expose similarly named environment variables (e.g. TF_VAR_vpc_id) and need to be consumed simultaneously by a single Stack.

Example Use Case:

We have separate base infrastructure Contexts for environments like prod and staging, each exporting variables like TF_VAR_vpc_id. Most stacks only need one Context, but occasionally a stack needs to consume both environments. A namespace prefix would allow both to coexist without conflict:

  • Attach prod Context with namespace prod → TF_VAR_prod_vpc_id

  • Attach staging Context with namespace stage → TF_VAR_stage_vpc_id

This avoids having to namespace all variables in the base Contexts upfront, which would complicate simpler use cases unnecessarily.

Proposed Behaviour:

Support an optional namespace string on Context attachments that is prepended to all exposed variable names (e.g. TF_VAR_{namespace}_{var}).

Workaround
The workaround is to prefix _all_ Context variables with the relevant namespace ahead of time. This does somewhat solve the problem but makes consuming the Context variables less ergonomic for the majority of the use cases.
Problem
-

Please authenticate to join the conversation.

Upvoters
Status

🔭 Discovery

Board

💡 Feature Requests

Tags

Contexts

Date

8 months ago

Subscribe to post

Get notified by email when there are changes.