Terraform v0.12.5
(I've also tried v1.30.0, v1.31.0, and v1.32.0 of provider.azurerm; the issue occurs in all of them)
This is the problem: we don't know
We have several .tf files in this environment; please review the debug log and let me know which one(s) you need to see
https://gist.github.com/nexxai/cce7e4a6b7097484db5963b23ecdb439 - signed via KeyBase
n/a
terraform plan
should have completed successfully
We receive two of these errors:
Error: insufficient items for attribute "sku"; must have at least 1
terraform plan
We have gone through and confirmed that every single SKU block in every single resource is formatted correctly. We have also tried backing up and then removing each SKU setting from each resource directly from the state file. Finally, in the azurerm_key_vault resources, we have tried every combination of sku
and sku_name
when we were using the v1.32.0 azurerm_provider
I was hoping that 1.32.1 of the azurerm provider would address this issue but it looks like it's still present in that version as well (unfortunately). I've tried wiping my state as well and it still persists. :(
Has anyone found a good workaround for this? It's a blocker for me at the moment.
For anyone interested I managed to find a workaround to this:
terraform state list
terraform destroy
).terraform state rm [resource name]
That's it, in my case I only had 1 offending resource; after deleting it, I could do terraform plan
and terraform apply
again.
Again, this worked for my scenario but ymmv.
@blinard We figured that out last night too. There were several App Services and their App Service Plans that had somehow been deleted through the portal, but I'm guessing that when Terraform was confirming their state, since the SKU field didn't even exist (since the App Service Plan was gone altogether), it was failing with the original error. All of this is supposition, but I feel like it makes the most sense?
If true, it would mean that the SKU checking on the various resources are making the assumption that the resource still exists when checking its value, rather than skipping the SKU check altogether.
@tombuildsstuff Thoughts?
@blinard That workaround was successful for us as well. My guess is that we did something wrong and de-synced the Terraform state with the actual infrastructure.
In any case, the "Error: insufficient items for attribute "sku"; must have at least 1" error message that's outputted isn't exactly ideal to pinpoint the issue.
Hey @nexxai, I believe this is the same issue as #3584 and was centered around app_service_plan not returning an error on 404 which is an assumption we make throughout the provider. We merged a workaround for #3584 that might unblock you if you feel comfortable testing it out by building the provider off of master. If that doesn't work we'll continue digging until we find the root cause of your issue.
I am having the same error, however in my case I haven't deleted any app service plans, instead I imported one and then started getting this error. I did notice that when I did an import, the sku was not set correctly in the state file. My guess is that there is an issue with the provider when it queries the state from azure to reconcile state vs. actual. I have tried modifying state to have the correct values, but I have not been successful yet.
@aweiker Could your issue by any chance be related to https://github.com/terraform-providers/terraform-provider-azurerm/issues/2991?
I noticed that I imported the app service plan via the URL
/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Web/serverFarms/instance1
instead of
/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Web/serverfarms/instance1
Notice the capitalization in serverfarms
in both URLs. Importing via the first one generated an empty sku and other fields, importing via the second one seems to import all fields perfectly fine.
@flagbug - What you found exactly described the root cause of my "insufficient items" error, I had deployed a linux ASP, which at the 58 min mark tf died, so after it finally provisioned I tried to import it and... this error kept on popping up and the state info was missing alot of things. Using the all lowercase serverfarms vs serverFarms on the import gave all the required info.
Most helpful comment
For anyone interested I managed to find a workaround to this:
terraform state list
terraform destroy
).terraform state rm [resource name]
That's it, in my case I only had 1 offending resource; after deleting it, I could do
terraform plan
andterraform apply
again.Again, this worked for my scenario but ymmv.