Just wondering if can someone able to assist to share some insights and lead me where to troubleshoot and fix the error below I just came across when I ran my Terraform Apply. I have TF code where the variable is set to default: "00000000-0000-0000-0000-000000000000". The intention is, If specified, identifies the landing zone resource deployment and correct placement in the Management Group hierarchy in our Azure environment.
Scripts for variable:
variable "subscription_id_landingzones" {
type = string
description = "If specified, identifies the landing zone resource deployment and correct placement in the Management Group hierarchy."
default = "00000000-0000-0000-0000-000000000000"
validation {
condition = can(regex("^[a-z0-9-]{36}$", var.subscription_id_landingzones)) || var.subscription_id_landingzones == ""
error_message = "Value must be a valid Subscription ID (GUID)."
}
}
locals {
subscription_id_landingzones = var.subscription_id_landingzones
}
provider "azurerm" {
skip_provider_registration = "true"
subscription_id = local.subscription_id_landingzones
features {}
alias = "landingzones"
}
Error Messages:
Error: populating Resource Provider cache: listing Resource Providers: loading results: unexpected status 404 (404 Not Found) with error: SubscriptionNotFound: The subscription ‘00000000-0000-0000-0000-000000000000’ could not be found.
troubleshoot RBAC permissions, secrets expiry and terraform files
2
Answers
in the Management Group, the SP has got Contributor role access. This role will also get inherited by the Subcriptions under that Management Group. I also tried to renew the client secret, eventhough it's not expired yet and updated the SP client secrets in the service connection config. FYI, I am using Azure Devops here. I re-ran the pipeline then and it's the same error.
The issue mentioned is due to is either related to wrong subscription ID or User doesn’t have any RBAC permissions as per the requirement.
As per Q&ADoc it seems the user doesn’t have necessary RBAC permission to read the subscription and if you’re using SP the check with the environment variables defined and updated the secret if it expires and create a new secret accordingly and update it.
My RBAC permissions
Configuration:
Deployment:
Refer:
https://learn.microsoft.com/en-us/azure/azure-resource-manager/management/overview
azurerm_storage_account | Resources | hashicorp/azurerm | Terraform | Terraform Registry
Difference between various contributor roles available in Azure and how to use it effectively? – Stack Overflow by User Sridevi – Stack Overflow