Skip to content

feat: Add environment variables to external team_authz commands#6348

Open
david-lawrence-tc wants to merge 5 commits intorunatlantis: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 intorunatlantis: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.

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>
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

2 participants