terraform-provider-azuredevops
terraform-provider-azuredevops copied to clipboard
Provider initialisation crashes when service URL is unreachable even if no resources are defined
Community Note
- Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
- Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
- If you are interested in working on this issue or have submitted a pull request, please leave a comment
Terraform (and Azure DevOps Provider) Version
Affected Resource(s)
- Provider init specific issue
Terraform Configuration Files
terraform {
required_providers {
azuredevops = {
source = "microsoft/azuredevops"
version = "0.2.0"
}
}
}
###########################################################
# Azure DevOps Project
###########################################################
resource "azuredevops_project" "project" {
name = var.devops_project_name
description = var.devops_project_description
}
resource "azuredevops_project_features" "project_features" {
count = 0
project_id = azuredevops_project.project.id
features = {
"testplans" = var.devops_project_features.testplans
"artifacts" = var.devops_project_features.artifacts
"boards" = var.devops_project_features.boards
"repositories" = var.devops_project_features.repositories
"pipelines" = var.devops_project_features.pipelines
"artifacts" = var.devops_project_features.artifacts
}
}
Expected Behavior
Provider should initialise successfully, or fail elegantly with a meaningful error message. We're not creating resources (configurable) in our scenario - we actually set the module count to 0 based on a feature flag, and the DevOps provider configuration sits inside the DevOps module
Actual Behavior
2022-08-16 13:19:57 a68c188d7953 root[88] INFO │ Error: Invalid provider configuration
2022-08-16 13:19:57 a68c188d7953 root[88] INFO │
2022-08-16 13:19:57 a68c188d7953 root[88] INFO │ Provider "registry.terraform.io/microsoft/azuredevops" requires explicit
2022-08-16 13:19:57 a68c188d7953 root[88] INFO │ configuration. Add a provider block to the root module and configure the
2022-08-16 13:19:57 a68c188d7953 root[88] INFO │ provider's required arguments as described in the provider documentation.
2022-08-16 13:19:57 a68c188d7953 root[88] INFO │
2022-08-16 13:19:57 a68c188d7953 root[88] INFO ╵
2022-08-16 13:19:57 a68c188d7953 root[88] INFO ╷
2022-08-16 13:19:57 a68c188d7953 root[88] INFO │ Error: Request returned status: 401 Unauthorized
2022-08-16 13:19:57 a68c188d7953 root[88] INFO │
2022-08-16 13:19:57 a68c188d7953 root[88] INFO │ with provider["registry.terraform.io/microsoft/azuredevops"],
2022-08-16 13:19:57 a68c188d7953 root[88] INFO │ on <empty> line 0:
2022-08-16 13:19:57 a68c188d7953 root[88] INFO │ (source code not available)
2022-08-16 13:19:57 a68c188d7953 root[88] INFO │
2022-08-16 13:19:57 a68c188d7953 root[88] INFO ╵
Steps to Reproduce
terraform apply
ADO provider will create all the required client connection before real resource create/update, delay the client initialization until real resource need to be create/update which should fix this issue, the error will be like 401 Unauthorized instead of Error: Invalid provider configuration.
@xuzhang3 Yes that would be much better - in our case where we feature toggle the entire module off we only need the provider to initialise successfully, even if the credentials are unauthorised, since when the module is toggled off no resources will be created, so it shouldn't fail
Is there a way to toggle the azuredevops provider to off.. I was forced to add the provider in a module, where i don't really have a azure devops provider url and pat token. Any workaround will be appreciated.