Description
Terraform Version
v1.7.4
Terraform Grafana Provider Version
v2.13.0
Grafana Version
v11.2.0
Affected Resource(s)
grafana_cloud_api_key, potentially more resources that use user provided data in resource ids
Terraform Configuration Files
resource "grafana_cloud_api_key" "test" {
cloud_org_slug = "myorg"
name = "service-a-production-admin"
role = "Admin"
}
Expected Behavior
Plan refreshed without errors.
Actual Behavior
Refresh plan errored out with the following error: Error: id "myorg-service-a-production-admin-production" does not match expected format. Should be in the format: orgSlug:apiKeyName
.
Steps to Reproduce
- Set grafana provider version to v1.43.0
- terraform init
- terraform plan
- terraform apply
- Set grafana provider version to v2.13.0
Important Factoids
Version v2.13.0 introduced the bug through this change: d6e8d1744
The "legacy" id parser introduced in this change is supposed to provide backward compatibility with resource ids created prior to introduction of standardised resource id format. However, the parser splits the id on every occurrence of "-" rather than on the first one, like previous versions did. This result in an id parsing error, number of parts is greater than expected, it should be 2 but in the example myorg-service-a-production-admin
we get 5.
This results in a confusing error message, Error: id "myorg-service-a-production-admin-production" does not match expected format. Should be in the format: orgSlug:apiKeyName
, that related to the standardised id format and does not mention the old one.
References
No response