Skip to content

[FEAT]: Support app auth and PAT via two provider instances #1537

@MajorBreakfast

Description

@MajorBreakfast

Describe the need

I'd like to be able to instantiate the GitHub provider twice. One instance uses app auth. The other instance uses personal access token (PAT) auth.

The code that I'd like to write looks like this:

provider "github" { # Uses GITHUB_APP_... env vars
  app_auth {}
}

provider "github" {  # Uses GITHUB_TOKEN env var
  alias = "pat"
}

The first provider block errors because, although I'm not explicitly setting the token argument, it is set implicitly due to the existence of the env var GITHUB_TOKEN.

Desired behavior:

  • app_auth {} block set => Provider uses the GITHUB_APP_... env vars (currently the case*), ignores GITHUB_TOKEN env var (new)
  • app_auth {} block not set => Provider uses the GITHUB_TOKEN env var (currently the case*), ignores GITHUB_APP_... env vars (currently the case*)

* I manually confirmed these statements about current behavior. In particular, the GITHUB_APP_... env vars are really ignored unless the app_auth {} block is set.

SDK Version

No response

API Version

No response

Relevant log output

│ Error: "app_auth": conflicts with token
│ 
│   with provider["registry.terraform.io/hashicorp/github"],
│   on main.tf line 1, in provider "github":
│    1: provider "github" {
│

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: TriageThis is being looked at and prioritizedType: FeatureNew feature or request

    Type

    No type

    Projects

    Status

    ✅ Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions