We use terraform to deploy resources to Snowflake using Snowflake terraform provider. I am trying to upgrade provider version and am getting errors when I do so:
Error: no schema available for snowflake_account_grant.resource_name while reading state; this is a bug in Terraform and should be reported
Error: no schema available for snowflake_grant_privileges_to_role.resurce_name while reading state; this is a bug in Terraform and should be reported
The error states that it is a bug in terraform but I am skeptical that that is actually the case as I shall now explain.
I have 14 errors of the form:
Error: no schema available for <snowflake_resource_type>.<snowflake_resource_name> while reading state; this is a bug in Terraform and should be reported
8 of the errors are for resource type snowflake_account_grant
5 of the errors are for resource type snowflake_grant_privileges_to_role
1 of the errors is for resource type snowflake_role_grants
that I am getting when running terraform plan
. However, immediately prior to that there are 14 warnings in the plan of the form:
│ Warning: Missing resource schema from provider
│No resource schema found for <snowflake_resource_type> when decoding prior
8 of the warnings are for resource type snowflake_account_grant
5 of the warnings are for resource type snowflake_grant_privileges_to_role
1 of the warnings is for resource type snowflake_role_grants
The change that I am making is to remove 8 resources of type snowflake_account_grant
, 5 of type snowflake_grant_privileges_to_role
and 1 of type snowflake_role_grants
. The reason I am removing them is that I am trying to upgrade the provider to the most recent version, 0.94.1, from a much older version, 0.68.2
and in version 0.93.0 those resource types have been removed, see Snowflake’s announcement of the deprecation at [❄️ Snowflake Official] The removal of deprecated grant resources · Snowflake-Labs/terraform-provider-snowflake · Discussion #2736 · GitHub.
Hence I am trying to follow their migration guide and replace the removed resources with their newer counterparts. Hence I have removed code like this:
resource "snowflake_account_grant" "monitor_task_execution" {
provider = snowflake.acc
privilege = "MONITOR EXECUTION"
roles = [
data.snowflake_role.ROLE1.name,
data.snowflake_role.ROLE2.name,
]
}
and replaced it with:
# remove the old resource from the state file
removed {
from = snowflake_account_grant.monitor_task_execution
lifecycle {
destroy = false
}
}
# define the new resource block
locals {
monitor_task_execution_roles = toset([
data.snowflake_role.ROLE1.name,
data.snowflake_role.ROLE2.name,
])
}
resource "snowflake_grant_privileges_to_account_role" "monitor_task_execution" {
for_each = local.monitor_task_execution_roles
provider = snowflake.acc
account_role_name = "\"${each.key}\""
privileges = ["MONITOR EXECUTION"]
with_grant_option = false
on_account = true
}
# import the already-existing resources to my state file
import {
for_each = local.monitor_task_execution_roles
to = snowflake_grant_privileges_to_account_role.monitor_task_execution[each.key]
id = "\"${each.key}\"|false|false|MONITOR EXECUTION|OnAccount"
}
The warning
│ Warning: Missing resource schema from provider
│No resource schema found for <snowflake_resource_type> when decoding prior
Makes me think that this is a problem with the provider rather than a bug in terraform which is what the error suggests.
So, why am I here? Basically I’m hoping someone can confirm my suspicion that this is indeed not a terraform bug and in fact I should be raising an issue at GitHub - Snowflake-Labs/terraform-provider-snowflake: Terraform provider for managing Snowflake accounts
Any thoughts would be appreciated.