hashicorp / terraform-provider-azurerm

Terraform provider for Azure Resource Manager
https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
Mozilla Public License 2.0
4.53k stars 4.6k forks source link

Service returned an error. Status=404 Code="ResourceNotFound" for ADLS Containers #17743

Open czuser129 opened 2 years ago

czuser129 commented 2 years ago

Is there an existing issue for this?

Community Note

Terraform Version

1.2.5

AzureRM Provider Version

3.8.0

Affected Resource(s)/Data Source(s)

azurerm_storage_data_lake_gen2_filesystem

Terraform Configuration Files

- adls.variables.tf

variable "adlsfilesystems" {
  type = string
}
variable "sta_id" {
  type = list(string)
}
variable "sta_name" {
  type = list(string)
}
variable "resourcegroupname" {
  type = string
}

- adls.main.tf

locals {
  staid = toset([
    for pair in sort(var.sta_name) : {
      staname  = pair
    }
  ])
}

resource "azurerm_storage_data_lake_gen2_filesystem" "storagedlsgen2fs" {
  for_each = { for p in local.staid : jsonencode(p) => p }
  name               = var.adlsfilesystems
  storage_account_id = join("",["/subscriptions/subscriptionID/resourceGroups/",var.resourcegroupname,"/providers/Microsoft.Storage/storageAccounts/",each.value["staname"]])
}

- main.tf

module "adlsfs" {
  for_each = var.adlsfilesystems
  source           = "../../adls/fs"
  adlsfilesystems  = each.value["name"]
  sta_id = module.adls.storage_account_ids
  sta_name = module.adls.storage_account_names
  resourcegroupname = module.resourcegroup.rgname.0
}

Debug Output/Panic Output

│ Error: creating File System "adlsfilesystem1" in Storage Account "testdls9404": datalakestore.Client#Create: Failure responding to request: StatusCode=404 -- Original Error: autorest/azure: Service returned an error. Status=404 Code="ResourceNotFound" Message="The specified resource does not exist.\nRequestId:31281827-601f-000c-0504-a07665000000\nTime:2022-07-25T08:56:59.6599009Z"
│ 
│   with module.adlsfs["adlsfilesystem1"].azurerm_storage_data_lake_gen2_filesystem.storagedlsgen2fs["{\"staname\":\"testdls9404\"}"],
│   on ../../../tf-core-module/adls/fs/filesystem.tf line 17, in resource "azurerm_storage_data_lake_gen2_filesystem" "storagedlsgen2fs":
│   17: resource "azurerm_storage_data_lake_gen2_filesystem" "storagedlsgen2fs" {

Expected Behaviour

No response

Actual Behaviour

No response

Steps to Reproduce

No response

Important Factoids

No response

References

No response

tombuildsstuff commented 2 years ago

@czuser129 can you provide the Terraform Configuration used to create the Storage Account? Not all Storage Account Types support all items, so it's specific to the SKU/Type being used

czuser129 commented 2 years ago

tombuildsstuff It is creating the datalake storage although fails on file system.

The storage config is as follows:

adls = { sa1 = { resourcetype = "dls" account_tier = "Standard" account_kind = "StorageV2" access_tier = "Hot" account_replication_type = "RAGRS" min_tls_version = "TLS1_2" is_hns_enabled = true dls = { dls = [ "test","dev" ] } } }

resource "azurerm_storage_account" "datalake" { for_each = var.adls name = "${var.dls_name}" resource_group_name = var.resourcegpname location = var.resourcelocation account_tier = var.account_tier account_replication_type = var.account_replication_type account_kind = var.account_kind access_tier = var.access_tier enable_https_traffic_only = true min_tls_version = var.min_tls_version is_hns_enabled = var.is_hns_enabled allow_nested_items_to_be_public = false }

variable "adls" { type = map(object({ account_tier = string account_kind = string access_tier = string account_replication_type = string min_tls_version = string is_hns_enabled = bool resourcetype = string rand_value = string dls = object({ dls = list(string) }) })) }

variable "resourcegpname" { type = string } variable "resourcelocation" { type = string } variable "hmac_key" { type = string } variable "account_tier" { type = string } variable "account_replication_type" { type = string } variable "account_kind" { type = string } variable "access_tier" { type = string } variable "min_tls_version" { type = string } variable "is_hns_enabled" { type = bool } variable "environmentshort" { type = string } variable "dls_name" { type = string } variable "rgtags" { type = map(string) } variable "ars_tags" { type = map(string) } variable "adlsfilesystems" { type = map(object({ name = string sa_id = string })) }