microsoft / terraform-provider-azuredevops

Terraform Azure DevOps provider
https://www.terraform.io/docs/providers/azuredevops/
MIT License
381 stars 272 forks source link

[FEAT]: `skip_provider_authentication` provider option #1176

Open jaredfholgate opened 1 week ago

jaredfholgate commented 1 week ago

Community Note

Description

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 Azure DevOps an GitHub 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 azuredevops and github 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 GitHub option, then we cannot expect them to supply working Azure DevOps credentials as they don't even have access to Azure DevOps.

This means that every module in our module tree has to have 3 versions: azuredevops, github 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 "azuredevops" {
   skip_provider_authentication = var.version_control_system == "github"
}

The obvious limitation with this is that if someone does reference an Azure DevOps 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.

New or Affected Resource(s)

This is a provider variable.

Potential Terraform Configuration

# Copy-paste your Terraform configurations here - for large Terraform configs,
# please use a service like Dropbox and share a link to the ZIP file. For
# security, you can also encrypt the files using our GPG public key.

References

jaredfholgate commented 1 week ago

Cross referencing the equivalent GitHub issue: https://github.com/integrations/terraform-provider-github/issues/2408