I have an error while trying to create a Blob Storage container with a private endpoint, while the Storage Account is “correctly” created, I get the following error
Error: checking for existing Container "my-container-name" (Account "Account "mystorageaccountname" (IsEdgeZone false / ZoneName "" / Subdomain Type "blob" / DomainSuffix "core.windows.net")"): executing request: unexpected status 403 (403 This request is not authorized to perform this operation.) with AuthorizationFailure: This request is not authorized to perform this operation
I have already review the permissions of the assigned roled to the Storage Account, my Terraform user has the correct permissions to perform all actions to create, modify and such cloud resources.
Here is the storage account, container, and blob storage configuration:
resource "azurerm_storage_account" "main" {
name = "${local.lower_service_name}${local.lower_slug_environment}storage"
resource_group_name = azurerm_resource_group.main.name
location = azurerm_resource_group.main.location
account_tier = "Standard"
account_replication_type = "LRS" # Locally Redundant Storage
account_kind = "StorageV2"
public_network_access_enabled = false
default_to_oauth_authentication = true
https_traffic_only_enabled = true
min_tls_version = "TLS1_2"
blob_properties {
versioning_enabled = true
change_feed_enabled = true
change_feed_retention_in_days = 90
last_access_time_enabled = true
delete_retention_policy {
days = 90
}
container_delete_retention_policy {
days = 30
}
}
}
resource "azurerm_storage_account_network_rules" "main" {
storage_account_id = azurerm_storage_account.main.id
default_action = "Deny"
ip_rules = []
bypass = ["AzureServices"]
virtual_network_subnet_ids = [module.storage_account_subnet.subnets_information["private-${local.service_name}-StorageAccount-1"].id]
}
# tfsec:ignore:azure-storage-no-public-access
resource "azurerm_storage_container" "main" {
name = "${local.lower_service_name}-${local.lower_environment}-storage-container"
storage_account_name = azurerm_storage_account.main.name
container_access_type = "private"
}
resource "azurerm_storage_blob" "main" {
name = "${local.lower_service_name}-${local.lower_environment}"
storage_account_name = azurerm_storage_account.main.name
storage_container_name = azurerm_storage_container.main.name
type = "Block"
access_tier = "Hot"
}
I have already tried using ChatGPT, Terraform Azure provider documentation, even a Chinese website that I found where they claim to have the solution to this specific problem, which they don’t, also, and lastly, Azure Documentation which is kinda confusing and not straightforward
José Angel Badillo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.