azureterraform

Disabling allow public blob access using terraform


I have created a storage account using a Terraform. I would like to disable the option found under the storage account settings and configuration in the Azure portal called Allow public blob access, however under the azurerm_storage_account command, I cannot seem to find the option required to achieve this.

Below is my code so far to create the storage account, which works, but if anyone could point me in the right direction that would be great, thank you.

Storage Account

resource "azurerm_storage_account" "st" {
    name = var.st.name
    resource_group_name = var.rg_shared_name
    location = var.rg_shared_location
    account_tier = var.st.tier
    account_replication_type = var.st.replication
    public_network_access_enabled = false
}

Solution

  • As soon as I've posted this question, I found the command, so I apologise for wasting your time.

    The command to use is allow_nested_items_to_be_public, if you set this to false it will disable the feature found under Storage Account > Settings > Configuration, Allow blob public access

    Source https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/storage_account#allow_nested_items_to_be_public

    Updated Code

    resource "azurerm_storage_account" "st" {
        name = var.st.name
        resource_group_name = var.rg_shared_name
        location = var.rg_shared_location
        account_tier = var.st.tier
        account_replication_type = var.st.replication
        public_network_access_enabled = false
        allow_nested_items_to_be_public = false
    }