-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Inconsistent Plan when using dynamic block which iterates through data source output (that is known at apply stage) #25600
Copy link
Copy link
Labels
bugconfirmeda Terraform Core team member has reproduced this issuea Terraform Core team member has reproduced this issuecore
Description
Terraform Version
Terraform v0.12.28
Terraform Configuration Files
provider "azurerm" {
features {}
}
variable "prefix" {
default = "magodoinconsist"
}
variable "location" {
default = "West Europe"
}
resource "azurerm_resource_group" "test" {
name = "${var.prefix}-rg"
location = var.location
}
resource "azurerm_storage_account" "test" {
name = "${var.prefix}sa"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
account_replication_type = "LRS"
account_tier = "Standard"
}
data "azurerm_monitor_diagnostic_categories" "test" {
resource_id = azurerm_storage_account.test.id
}
resource "azurerm_monitor_diagnostic_setting" "test" {
name = "${var.prefix}-ds"
target_resource_id = azurerm_storage_account.test.id
storage_account_id = azurerm_storage_account.test.id
dynamic "log" {
for_each = data.azurerm_monitor_diagnostic_categories.test.logs
content {
category = log.key
}
}
dynamic "metric" {
for_each = data.azurerm_monitor_diagnostic_categories.test.metrics
content {
category = metric.key
}
}
}Debug Output
https://gist.github.com/magodo/3a2221ef7cb0af4e4d2d6e1fae5537e7
Crash Output
Error: Provider produced inconsistent final plan
When expanding the plan for azurerm_monitor_diagnostic_setting.test to include
new values learned so far during apply, provider
"registry.terraform.io/-/azurerm" produced an invalid new value for .log:
planned set element
cty.ObjectVal(map[string]cty.Value{"category":cty.UnknownVal(cty.String),
"enabled":cty.True,
"retention_policy":cty.ListValEmpty(cty.Object(map[string]cty.Type{"days":cty.Number,
"enabled":cty.Bool}))}) does not correlate with any element in actual.
This is a bug in the provider, which should be reported in the provider's own
issue tracker.
Error: Provider produced inconsistent final plan
When expanding the plan for azurerm_monitor_diagnostic_setting.test to include
new values learned so far during apply, provider
"registry.terraform.io/-/azurerm" produced an invalid new value for .metric:
planned set element
cty.ObjectVal(map[string]cty.Value{"category":cty.UnknownVal(cty.String),
"enabled":cty.True,
"retention_policy":cty.ListValEmpty(cty.Object(map[string]cty.Type{"days":cty.Number,
"enabled":cty.Bool}))}) does not correlate with any element in actual.
This is a bug in the provider, which should be reported in the provider's own
issue tracker.
Expected Behavior
The provision shall be successful with one terraform apply.
Actual Behavior
The provision will panic at first apply. While a second apply will succeed.
Steps to Reproduce
terraform initterraform apply
Additional Context
The azurerm provider version is v2.18.0.
I understand the reason of the issue here, while I want to figure out if this is an official solution for this, or if this is some known issue to be fixed in core?
References
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugconfirmeda Terraform Core team member has reproduced this issuea Terraform Core team member has reproduced this issuecore