Reputation: 949
My GitLab CI/CD pipeline is throwing a Terraform Azuread provider authoriser error which has become a major blocker for me and I simply can't find a way round it.
My Terraform configuration includes a data.tf file which has the following single line entry:
data "azuread_client_config" "current" {}
I also have a provider.tf file, the content of which includes the following azuread provider block:
provider "azuread" {
tenant_id = "#TenantID#"
use_cli = "false"
}
Running the GitLab CI/CD pipeline, it throws the below error:
Error: no Authorizer could be configured, please check your configuration
with provider ["registry.terraform.io/hashicorp/azuread"],
on provider.tf line 29, in provider "azuread":
29: provider "azuread" {
If I exclude the data.tf file from my terraform configuration or comment out its single line entry, the pipeline runs without throwing any errors. What am I doing wrong, or what do I need to do to get the pipeline run successfully, upon inclusion of the data.tf file?
Upvotes: 2
Views: 9143
Reputation: 4602
Data Source: azuread_client_config
Use this data source to access the configuration of the AzureAD provider.
#This is while Terraform authenticating via the Azure CLI
data "azuread_client_config" "current" {}
output "object_id" {
value = data.azuread_client_config.current.object_id
}
#Configure the Azure Active Directory Provider
provider "azuread" {
# NOTE: Environment Variables can also be used for Service Principal authentication
# client_id = "..."
# client_secret = "..."
# tenant_id = "..."
}
So would suggest you remove data "azuread_client_config" "current" {}
line from data.tf
file if you are using provider azuread {}
in provider.tf file. Because you are already authenticating with Service Principle so there is no point of using data source of azuread.
You can also refer this Documention regarding the Data Sources
and Resources
supported by the Azure Active Directory Provider
Upvotes: 2