Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot import azurerm_storage_share #130

Closed
CNBoland opened this issue Jun 9, 2022 · 1 comment · Fixed by #150
Closed

Cannot import azurerm_storage_share #130

CNBoland opened this issue Jun 9, 2022 · 1 comment · Fixed by #150
Labels
bug Something isn't working

Comments

@CNBoland
Copy link

CNBoland commented Jun 9, 2022

Attempting to import azurerm_storage_share. The resource doesn't appear in generated main.tf, but the resource is listed in .aztfyResourceMapping.json with empty address:

"/subscriptions//resourceGroups/FC-AZ-RG-USC-Dev-Foo/providers/Microsoft.Storage/storageAccounts/fcazstgdevfoo/fileServices/default/shares/processing-share": ""

The storage share resource was originally created with Terraform v0.14.11 and AzureRM v3.9:

resource "azurerm_storage_account" "storage_account" {
  name                     = "fcazstgdevfoo"
  location                 = "Central US"
  resource_group_name      = "FC-AZ-RG-USC-Dev-Foo"
  account_tier             = "Standard"
  account_replication_type = "LRS"
  ...
}

resource "azurerm_storage_share" "processing-share" {
  name                 = "processing-share"
  storage_account_name = "fcazstgdevfoo"
  quota                = 50
}

I updated .aztfyResourceMapping.json with the appropriate address:

"/subscriptions//resourceGroups/FC-AZ-RG-USC-Dev-Foo/providers/Microsoft.Storage/storageAccounts/fcazstgdevfoo/fileServices/default/shares/processing-share": "azurerm_storage_share.processing-share"

then ran the import again, referencing the updated mapping file (I copied updated mapping file to parent folder for safekeeping):

aztfy -m ..\.aztfyResourceMapping.json FC-AZ-RG-USC-Dev-Foo

Resources are listed in aztfy, with an error on the storage share:

  exit status 1

  Error: Cannot import non-existent remote object

  While attempting to import an existing object to
  "azurerm_storage_share.processing-share", the provider detected that no
  object exists with the given id. Only pre-existing objects can be imported;
  check that the id is correct and that it is associated with the provider's
  configured region or endpoint, or use "terraform apply" to create a new
  remote object for this resource.

Am I doing something wrong here? Should address to the storage share be something other than <resource type>.<resource name> in this case?

@magodo magodo added the bug Something isn't working label Jun 10, 2022
@magodo
Copy link
Collaborator

magodo commented Jun 10, 2022

@CNBoland Thank you for submitting this! The reason of the failure is that Terraform expects the data plane ID of the storage share, while ARM returns its mgmt plane ID. There needs a special handling for this. Will submit a fix soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants