close
Skip to content

feat: Add environment variables to external team_authz commands#6348

Open
david-lawrence-tc wants to merge 5 commits into
runatlantis:mainfrom
david-lawrence-tc:add-team-allowlist-ctx-env-vars
Open

feat: Add environment variables to external team_authz commands#6348
david-lawrence-tc wants to merge 5 commits into
runatlantis:mainfrom
david-lawrence-tc:add-team-allowlist-ctx-env-vars

Conversation

@david-lawrence-tc
Copy link
Copy Markdown

what

Adds additional environment variables to external authz commands:

  • WORKSPACE - The Terraform workspace used for the project, ex. default
  • API - "true" if invoked by API endpoints
  • VERBOSE - "true" when the user would like verbose output

why

  • It is common to map terraform workspaces to environments (for example dev, stage, prod)
  • This allows an external authz script to allow/deny commands based on workspace name
  • For example to allow broader access for lower environments, but keep prod workspaces more restricted
  • This is not currently possible to do with external authz because the WORKSPACE env var is not passed to this command

tests

  • Added unit tests
  • Deployed this version to my environment and verified the new environments variables are passed to the script without errors

references

closes #6342

…ternal shell command including

* WORKSPACE
* API
* VERBOSE

Signed-off-by: David Lawrence <161499966+david-lawrence-tc@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 27, 2026 16:08
@dosubot dosubot Bot added feature New functionality/enhancement go Pull requests that update Go code labels Mar 27, 2026
@github-actions github-actions Bot added the docs Documentation label Mar 27, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds additional context to external team allowlist/authz command executions by exporting more information via environment variables.

Changes:

  • Pass WORKSPACE, API, and VERBOSE env vars to external team allowlist commands.
  • Add unit tests covering the new env vars (plus some existing env behaviors).
  • Document the newly supported env vars in the permissions docs.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
server/core/runtime/external_team_allowlist_runner.go Exports WORKSPACE, API, and VERBOSE in the runner’s environment.
server/core/runtime/external_team_allowlist_runner_test.go Adds test coverage for env propagation and runner behavior.
runatlantis.io/docs/repo-and-project-permissions.md Documents the additional env vars available to external commands.

Comment thread server/core/runtime/external_team_allowlist_runner.go
Comment thread server/core/runtime/external_team_allowlist_runner.go
Comment thread server/core/runtime/external_team_allowlist_runner_test.go Outdated
Comment thread server/core/runtime/external_team_allowlist_runner_test.go Outdated
Comment thread runatlantis.io/docs/repo-and-project-permissions.md Outdated
Signed-off-by: David Lawrence <161499966+david-lawrence-tc@users.noreply.github.com>
Signed-off-by: David Lawrence <161499966+david-lawrence-tc@users.noreply.github.com>
Signed-off-by: David Lawrence <161499966+david-lawrence-tc@users.noreply.github.com>
Signed-off-by: David Lawrence <161499966+david-lawrence-tc@users.noreply.github.com>
@lukemassa
Copy link
Copy Markdown
Contributor

WORKSPACE makes sense to me, but I'm not sure about API and VERBOSE.

VERBOSE in particular, it's hard for me to think of a reason why this would be useful in an authorization decision.

As for API, that's a very generic term, and I could imagine may confuse or even conflict with other environment variables.

My vote here would be to add just WORKSPACE, as it solves the immediate problem, then add additional env vars as needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation feature New functionality/enhancement go Pull requests that update Go code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Workspace Environment Variable to External Team Authz Commands

3 participants