Open mpigram1 opened 2 months ago
I've had to pull my provider version back to 3.112.0
to stop this error from happening.
Not ideal considering I'd made changes that incorporated some new features.
Any help regarding this would be great but for now I'm unblocked.
This happened to me after I applied with 4.0.1, and then tried to apply again with 4.1.0.
Solved by manually editing the state file and changing schema_version
of cosmosdb to 1.
Thanks for raising this issue. Seems I can't reproduce this issue after the version is upgraded from 3.116.0 to 4.1.0. Please check and ensure if "ip_range_filter" is string type in the state file. If yes, please directly update to 4.1.0 to see if the issue still exists? Thanks.
tf config:
provider "azurerm" {
features {}
}
resource "azurerm_resource_group" "test" {
name = "acctestRG-cosmos-test06"
location = "eastus"
}
resource "azurerm_virtual_network" "test" {
name = "acctest-VNET-test06"
resource_group_name = azurerm_resource_group.test.name
address_space = ["10.0.0.0/16"]
location = azurerm_resource_group.test.location
dns_servers = ["10.0.0.4", "10.0.0.5"]
}
resource "azurerm_subnet" "subnet1" {
name = "acctest-SN1-test06-1"
resource_group_name = azurerm_resource_group.test.name
virtual_network_name = azurerm_virtual_network.test.name
address_prefixes = ["10.0.1.0/24"]
private_endpoint_network_policies = "Disabled"
private_link_service_network_policies_enabled = false
}
resource "azurerm_subnet" "subnet2" {
name = "acctest-SN2-test06-2"
resource_group_name = azurerm_resource_group.test.name
virtual_network_name = azurerm_virtual_network.test.name
address_prefixes = ["10.0.2.0/24"]
service_endpoints = ["Microsoft.AzureCosmosDB"]
private_endpoint_network_policies = "Disabled"
private_link_service_network_policies_enabled = false
}
resource "azurerm_cosmosdb_account" "test" {
name = "acctest-ca-test06"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
offer_type = "Standard"
kind = "GlobalDocumentDB"
is_virtual_network_filter_enabled = true
virtual_network_rule {
id = azurerm_subnet.subnet1.id
ignore_missing_vnet_service_endpoint = true
}
virtual_network_rule {
id = azurerm_subnet.subnet2.id
ignore_missing_vnet_service_endpoint = false
}
analytical_storage {
schema_type = "WellDefined"
}
backup {
type = "Continuous"
}
capacity {
total_throughput_limit = 200
}
consistency_policy {
consistency_level = "Eventual"
max_interval_in_seconds = 5
max_staleness_prefix = 100
}
geo_location {
location = azurerm_resource_group.test.location
failover_priority = 0
zone_redundant = false
}
}
Reproduce steps:
Step 1 - Run "tf apply" with above tf config and v3.115.0
Step 2 - Upgrade version to v4.1.0 and run "tf plan"
I can reproduce using @neil-yechenwei's config using these steps:
terraform plan
now causes this issue, so remove azurerm_cosmosdb_account.test
from state and re-import itterraform plan
is now successful, ip_range_filter
in state has now been changed from ""
to []
terraform plan
now causes the panic: interface conversion: interface {} is []interface {}, not string
errorSo it seems to affect configs that first upgraded to 4.0.1 using the remove/import workaround, then upgrade to 4.1.0.
ETA: Removing and re-importing the account under 4.1.0 works, as does going directly from 3.116.0 -> 4.1.0 without first going to 4.0.1.
I also get the panic if I create the resources under 4.0.1 and then upgrade to 4.1.0. Removing and re-importing also fixes things in this situation.
Getting the same error after remove/import on 4.0.1 and now going to version 4.1.0
I'm also getting the same error after remove/import cosmos db account on 4.0.1 and now going to version 4.1.0 from version 4.0.1. Getting this issues only on environment having cosmosdb setup.
v3.115.0 -> v4.0.1 broke ip_range_filter
changing from string of ips "10.0.0.1,10.0.0.2" to array with CIDR notation ["10.0.0.1/32", "10.0.0.2/32"]. terraform would reply with: Error: missing expected [
even after updating code with existing cosmosdb resource. Here: https://github.com/hashicorp/terraform-provider-azurerm/issues/27242
v4.0.1 -> v4.1.0 broke as this provider error in OP.
If you fixed your state file manually by removing that field or reimported the cosmosdb then your schema_version
for resource azurerm_cosmosdb_account
will be 0. Changing this to 1 has fixed this issue for me. Or you could try reimporting your cosmosdb if possible?
Fixed the bug from earlier and then create a new bug. Lol. https://github.com/hashicorp/terraform-provider-azurerm/pull/27276
Note: I didn't reimport my resource, I modified the state file which is not best practice.. So not sure the behaviour of schema_version
with an import.
v3.115.0 -> v4.0.1 broke
ip_range_filter
changing from string of ips "10.0.0.1,10.0.0.2" to array with CIDR notation ["10.0.0.1/32", "10.0.0.2/32"]. terraform would reply with:Error: missing expected [
even after updating code with existing cosmosdb resource. Here: #27242v4.0.1 -> v4.1.0 broke as this provider error in OP.
If you fixed your state file manually by removing that field or reimported the cosmosdb then your
schema_version
for resourceazurerm_cosmosdb_account
will be 0. Changing this to 1 has fixed this issue for me. Or you could try reimporting your cosmosdb if possible?Fixed the bug from earlier and then create a new bug. Lol. #27276
Note: I didn't reimport my resource, I modified the state file which is not best practice.. So not sure the behaviour of
schema_version
with an import.
@dansali, I don't want to change the state files by own. I have many cosmos db accounts and remove/reimport took me 2 days to complete it as a workaround for the previous version. now again doing the same for this version will cause any issue in next version. Better I will wait for fixing this issue fully in next release will help me with small work.
I could see you merged some code and do we need to remove and reimport resource from tfstate file for cosmosdb account? or can we wait for next release to fix this issue fully?
Better I will wait for fixing this issue fully in next release will help me with small work.
You could enforce your azurerm provider to v4.0.1 to bypass this issue until it's hopefully fixed in a future release.
@babuga365 I think that could work
@babuga365 I recommended a fix for this one for the developer who wrote this. I didn't merge anything, just went through same issue migrating from v4.0.1 to v4.1.0
https://github.com/hashicorp/terraform-provider-azurerm/pull/27276#issuecomment-2341494537
@orgads thanks for the workaround, it worked here!
Better I will wait for fixing this issue fully in next release will help me with small work.
You could enforce your azurerm provider to v4.0.1 to bypass this issue until it's hopefully fixed in a future release.
@babuga365 I think that could work
@dansali , I have already migrated from v3.116.0 to v4.0.1 I will wait for one more release with final fix. I don't want to keep on doing same remove/re-import resource in state file as workarounds
There is a fix for the panic during migration from 4.0.1
to 4.1.0
in https://github.com/hashicorp/terraform-provider-azurerm/pull/27302, which will release in 4.2.0
. Directly migration from 3.x
to 4.1.0
should have no issue.
If you met the panic issue during migration from 4.0.1
to 4.1.0
. You can workaround the issue by terraform state rm
followed by terraform import
the azurerm_cosmosdb_account
resources.
thanks.
Is there an existing issue for this?
Community Note
Terraform Version
Terraform v1.9.5 on linux_amd64
AzureRM Provider Version
provider registry.terraform.io/hashicorp/azurerm v4.1.0
Affected Resource(s)/Data Source(s)
azurerm_cosmosdb_account
Terraform Configuration Files