terraform-provider-google: Error: Provider produced inconsistent final plan - google_dns_record_set - rrdatas list with unknown value
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.
- If an issue is assigned to the
modular-magicianuser, it is either in the process of being autogenerated, or is planned to be autogenerated soon. If an issue is assigned to a user, that user is claiming responsibility for the issue. If an issue is assigned tohashibot, a community member has claimed the issue already.
Issue:
Using a value that is unknown until apply in the rrdatas list of a google_dns_record_set resource causes an inconsistent plan error.
Terraform Version
Terraform v1.2.4 on linux_amd64
Affected Resource(s)
- google_dns_record_set
Terraform Configuration Files
terraform {
required_providers {
google = {
source = "hashicorp/google"
version = ">= 4.24.0"
}
random = {
version = ">= 3.3.2"
}
}
}
resource "random_id" "project_id" {
keepers = {
project_id = "my-project"
}
byte_length = 8
prefix = "project-"
}
resource "google_project" "my_project" {
name = "my-${random_id.project_id.hex}"
project_id = "${random_id.project_id.hex}"
}
resource "google_dns_record_set" "cdn_dns_txt_record_firebase" {
name = "www.example.com"
project = google_project.my_project.project_id
managed_zone = "example.com."
type = "TXT"
ttl = 300
rrdatas = ["\"v=spf1 include:_spf.firebasemail.com ~all\"", "firebase=${google_project.my_project.id}"]
}
Debug Output
https://gist.github.com/zymotik/5ad37a5534314b835d64a48358b8ddf6
Panic Output
Error: Provider produced inconsistent final plan
When expanding the plan for google_dns_record_set.cdn_dns_txt_record_firebase to include new values learned so far during apply, provider
"registry.terraform.io/hashicorp/google" produced an invalid new value for .rrdatas: was null, but now cty.ListVal([]cty.Value{cty.StringVal("\"v=spf1
include:_spf.firebasemail.com ~all\""), cty.StringVal("firebase=projects/project-bf0a809a64d28d47")}).
This is a bug in the provider, which should be reported in the provider's own issue tracker.
Expected Behavior
Plan should include rrdatas element on the google_dns_record_set.cdn_dns_txt_record_firebase resource indicating value known after apply.
Actual Behavior
Error reported:
Error: Provider produced inconsistent final plan
Steps to Reproduce
terraform apply
References
This issue maybe related:
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 1
- Comments: 15 (6 by maintainers)
Some more information! I’m sharing this just for completeness since I don’t know yet what is useful, since I’ve not yet learned enough to actually have an answer to what’s going on here.
The
d.GetChangemethod wraps a hidden abstraction called a “field reader”. The field reader for the diff uses a shared helper function to deal with reading lists, which treats unknown lists and empty lists in the same way, but does signal unknown lists by populating the field “computed”, which is some confusing legacy SDK terminology to mean “unknown”:https://github.com/hashicorp/terraform-plugin-sdk/blob/4681738a561387fb0b3aaa69aeb42231383634a0/helper/schema/field_reader.go#L189-L196
Unfortunately, the
ResourceDiff.GetChangemethod just discards everything except the value:https://github.com/hashicorp/terraform-plugin-sdk/blob/4681738a561387fb0b3aaa69aeb42231383634a0/helper/schema/resource_data.go#L68-L77
So when you call
d.GetChangethere is no way to distinguish an unknown list from a known empty list.