integrations / terraform-provider-github

Terraform GitHub provider
https://www.terraform.io/docs/providers/github/
MIT License
912 stars 754 forks source link

[FEAT]: `skip_provider_authentication` provider option #2408

Open jaredfholgate opened 1 month ago

jaredfholgate commented 1 month ago

Describe the need

I appreciate this is something of an edge case, but it would help to significantly reduce the amount of code we have to managed in our Azure Landing Zones and Azure Verified Modules.

We support both GitHub and Azure DevOps as options for our customers to bootstrap their version control system.

Due to a limitation of Terraform Core, we are unable to reference both the github and azuredevops provider in the same module. Terraform Core does not support optional providers. It always attempts to initialise the provider even if no resources or data sources for that provider are part of the graph.

If someone chooses the Azure DevOps option, then we cannot expect them to supply working GitHub credentials as they don't even have access to GitHub.

This means that every module in our module tree has to have 3 versions: github, azuredevops and local (local file system). This is a significant maintenance overhead requiring a lot of copy and paste code.

In order to work around this it would be great if we could add a flag that skips attempting to auth the provider and just returns a success from the init command.

e.g.

provider "github" {
   skip_provider_authentication = var.version_control_system == "azuredevops"
}

The obvious limitation with this is that if someone does reference a GitHub resource or data source when this provider variable is set they will get an auth error.

If this is something you think could work I would be happy to submit a PR for the code.

SDK Version

No response

API Version

No response

Relevant log output

No response

Code of Conduct

jaredfholgate commented 1 month ago

Cross referencing the equivalent Azure DevOps issue: https://github.com/microsoft/terraform-provider-azuredevops/issues/1176