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

Terraform plan fails if the Storage Account referenced in azurerm_storage_management_policy was deleted outside of Terraform #12933

Closed
ZachTB123 opened this issue Aug 10, 2021 · 2 comments · Fixed by #14799

Comments

@ZachTB123
Copy link

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform (and AzureRM Provider) Version

  • Terraform version: v1.0.0
  • AzureRM Provider version: v2.71.0

Affected Resource(s)

  • azurerm_storage_management_policy

Terraform Configuration Files

provider "azurerm" {
  features {}
}

resource "azurerm_resource_group" "example" {
  name     = "example-resource-group"
  location = "centralus"
}

resource "azurerm_storage_account" "example" {
  name                      = "jneafknzeae" # Random name for demo purposes
  resource_group_name       = azurerm_resource_group.example.name
  location                  = azurerm_resource_group.example.location
  account_kind              = "StorageV2"
  account_tier              = "Standard"
  access_tier               = "Hot"
  account_replication_type  = "LRS"
  enable_https_traffic_only = true
  min_tls_version           = "TLS1_2"
  allow_blob_public_access  = false
}

resource "azurerm_storage_management_policy" "example" {
  storage_account_id = azurerm_storage_account.example.id

  rule {
    name    = "Example-Rule"
    enabled = true
    filters {
      blob_types = ["blockBlob"]
    }
    actions {
      base_blob {
        delete_after_days_since_modification_greater_than = 30
      }
    }
  }
}

Debug Output

Panic Output

Expected Behaviour

A drift is properly detected and the Storage Account / policy are recreated.

Actual Behaviour

Terraform plan fails with:

│ Error: storage.ManagementPoliciesClient#Get: Failure responding to request: StatusCode=404 -- Original Error: autorest/azure: Service returned an error. Status=404 Code="ResourceNotFound" Message="The Resource 'Microsoft.Storage/storageAccounts/jneafknzeae' under resource group 'example-resource-group' was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix"
│ 
│   with azurerm_storage_management_policy.example,
│   on main.tf line 23, in resource "azurerm_storage_management_policy" "example":
│   23: resource "azurerm_storage_management_policy" "example" {

Since plan fails, we are unable to recreate the Storage Account.

Steps to Reproduce

  1. terraform apply the above configuration
  2. Go into the Azure portal and manually delete the Storage Account (or use the CLI, etc.)
  3. terraform plan the above configuration

Important Factoids

References

@github-actions
Copy link

github-actions bot commented Jan 7, 2022

This functionality has been released in v2.91.0 of the Terraform Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@github-actions
Copy link

github-actions bot commented Feb 7, 2022

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 7, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
2 participants