I am trying to deploy resources to Azure from Jenkins using Terraform. I have created a Service principal in Azure and added the credentials in Jenkins. (SP has contributor level access)
In the pipeline script, I have added sh step to authenticate with AzCLI. (Followed the procedure in TF docs). - This works fine
But, somehow Terraform is not able to get through Azure with these credentials. I am getting an error at terraform init.
The error I see is “error building azurerm client: authenticating using the azure cli is only supported as a user (not a service principal).”
What is the best practice to make terraform work with Azure?