Terraform code getting authorization issue

Vasanthi 0 Reputation points
2024-10-29T02:09:02.6+00:00

I am trying to create resource group using terraform code from my desktop. But getting authorization issue.

PS G:\Terraform> terraform plan

Planning failed. Terraform encountered an error while generating this plan.

│ Error: populating Resource Provider cache: listing Resource Providers: loading results: unexpected status 403 (403 Forbidden) with error: AuthorizationFailed: The client '939b9121-6ee1-4fec-b9a6-ea4de188f322' with object id '939b9121-6ee1-4fec-b9a6-ea4de188f322' does not have authorization to perform action 'Microsoft.Resources/subscriptions/providers/read' over scope '/subscriptions/4fd09b74-6933-4f16--********' or the scope is invalid. If access was recently granted, please refresh your credentials.

│ with provider["registry.terraform.io/hashicorp/azurerm"],

│ on create_resource.tf line 10, in provider "azurerm":

│ 10: provider "azurerm" {

Microsoft Security Microsoft Entra Microsoft Entra ID
{count} votes

1 answer

Sort by: Most helpful
  1. Navya 19,795 Reputation points Microsoft External Staff Moderator
    2024-10-29T07:13:56.1266667+00:00

    Hi @Vasanthi

    Thank you for posting this in Microsoft Q&A.

    I understand that you are trying to create a resource group using Terraform code but are encountering an authorization issue.

    The error message you are receiving indicates that the Azure client (identified by the client ID 939b9121-6ee1-4fec-b9a6-ea4de188f322) does not have the necessary permissions to perform the action required to create a resource group in the specified subscriptions.

    Could you please check what type of RBAC role you have assigned on the subscription? To create resource groups, you need at least the Contributor role. Additionally, please verify that you are using the correct subscription ID for which you have permissions.

    Hopes this helps! Do let us know if you have any further queries.

    Thanks,

    Navya.

    If this answers your query, do click Accept Answer and Yes for was this answer helpful. And, if you have any further query do let us know.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.