Terraform-provider-azurerm: Error running `terraform plan` on App Service Plan deleted outside of Terraform

Created on 4 Jun 2019  ·  10Comments  ·  Source: terraform-providers/terraform-provider-azurerm

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 v0.12.0
+ provider.azurerm v1.29.0

Affected Resource(s)

  • azurerm_app_service_plan

Terraform Configuration Files

resource "azurerm_resource_group" "example" {
  name     = "example-resources"
  location = "westeurope"
}

resource "azurerm_app_service_plan" "example" {
  name                = "example-plan"
  location            = azurerm_resource_group.example.location
  resource_group_name = azurerm_resource_group.example.name

  sku {
    tier = "Basic"
    size = "B1"
  }
}

Debug Output

https://gist.github.com/joakimhellum-in/7a5d2d065d178f85add5e2c037304f87

Panic Output

N/A

Expected Behavior

Terraform to plan resource changes.

Actual Behavior

Terraform exits with an error message:
Error: insufficient items for attribute "sku"; must have at least 1

Steps to Reproduce

  1. Run terraform init.
  2. Run terraform apply.
  3. Delete the App Service Plan outside of Terraform, for example: az appservice plan delete -n example-plan -g example-resources.
  4. Run terraform plan.

Important Factoids

  • Error occurs when running terraform plan on an App Service Plan that has been deleted outside of Terraform.
  • Can reproduce issue on Terraform v0.12 (v0.12.0 and build from master), but not v0.11.
  • So far I didn't experience this with other resources that uses similar sku attribute.

References

bug servicapp-service

Most helpful comment

The workaround has been merged and will it make it into the next release. Closing this down but feel free to reopen if you continue to have issues after the next release goes out.

All 10 comments

Same issues, the problem was solved by removing the tfstate file (it was a test environment)

Same issue with azurerm_sql_server. Removing tfstate worked.

I'm having the same issue with:

Terraform v0.12.4

  • provider.azurerm v1.32.0

I'm trying to recreate a lost tfstate file using import, so obviously deleting it tfstate file is not going to solve my problem

still having the problem in version 0.12.6

Workarounded by provider.azurerm version downgrade to 1.27.0, Terraform version is still 0.12.4

Hey all. Thanks for opening this issue @joakimhellum-in. It looks like the azure sdk for app service plans doesn't return an error on 404 which is how we normally handle a deletion outside of terraform. I've implemented a workaround with #3990 and opened an issue on the sdk repo to get this addressed. Thanks for your patience here!

The workaround has been merged and will it make it into the next release. Closing this down but feel free to reopen if you continue to have issues after the next release goes out.

Workarounded by provider.azurerm version downgrade to 1.27.0, Terraform version is still 0.12.4
it worked!! thaaanks!

I has been released:

provider "azurerm" {
  version         = "~> 1.33.0"
}

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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks!

Was this page helpful?
0 / 5 - 0 ratings