Search code examples
azureterraformazure-storageterraform-provider-azure

Azure Storage: Error checking for existence of existing Storage Share


I'm trying to provision an Azure storage account and file share using Terraform:

resource "random_pet" "prefix" {}

provider "azurerm" {
  version = "~>2.25.0"
  features {}
}

resource "azurerm_resource_group" "default" {
  name     = "${random_pet.prefix.id}-rg"
  location = "australiaeast"
}


resource "azurerm_storage_account" "default" {
  name                = replace("${random_pet.prefix.id}storage", "-", "")
  resource_group_name = azurerm_resource_group.default.name
  location            = azurerm_resource_group.default.location
  account_tier        = "Premium"
  account_replication_type = "LRS"
}

resource "azurerm_storage_share" "default" {
  name = "${azurerm_storage_account.default.name}share"
  storage_account_name = azurerm_storage_account.default.name
}

However I'm getting the following error when attempting to apply:

Error: Error checking for existence of existing Storage Share "patientducklingstorageshare" (Account "patientducklingstorage" / Resource Group "patient-duckling-rg"): shares.Client#GetProperties: Failure sending request: StatusCode=0 -- Original Error: Get "https://patientducklingstorage.file.core.windows.net/patientducklingstorageshare?restype=share": dial tcp: lookup patientducklingstorage.file.core.windows.net on 192.168.1.1:53: no such host

  on aks-cluster.tf line 22, in resource "azurerm_storage_share" "default":
  61: resource "azurerm_storage_share" "default" {
``

Solution

  • This issue was resolved by running terraform init.