terraform-provider-snowflake
terraform-provider-snowflake copied to clipboard
SQL compilation error on snowflake_role_grant if target role removed
These seems to be the same issue that #432 resolved but on role grants instead of database grant.
If a target role "role_name" for snowflake_role_grant gets removed, terraform plan fails due to the SQL error shown. This occurs even when the target role is managed by terraform and would be created on successful run.
TF resources:
// Terraform typescript CDK
const db_owner = new snow.Role(scope, `role-${dbName}-owner`, {
name: "OWNER_" + db.name,
});
new snow.RoleGrants(scope, `grant_${dbName}_owner_to_sysadmin`, {
roles: ["SYSADMIN"],
roleName: db_owner.name,
});
Resulting error:
╷
│ Error: 002003 (02000): SQL compilation error:
│ Role 'OWNER_DEMO_DB' does not exist or not authorized.
│
│ with snowflake_role_grants.grant_OWNER_DEMO_DB_owner_to_sysadmin,
│ on snowflake-accounts.qa.tf.json line 266, in resource.snowflake_role_grants.grant_DEMO_DB_owner_to_sysadmin:
│ 266: },
│
Same issue here. Refresh fails when the role has been deleted outside of terraform:
terraform apply -var-file account.tfvars
snowflake_role.prod_jaffles_admin: Refreshing state... [id=PROD_JAFFLES_ADMIN]
snowflake_role_grants.prod_jaffles_admin: Refreshing state... [id=PROD_JAFFLES_ADMIN]
╷
│ Error: 002003 (02000): SQL compilation error:
│ Role 'PROD_JAFFLES_ADMIN' does not exist or not authorized.
│
│ with snowflake_role_grants.prod_jaffles_admin,
│ on prod-jaffles.tf line 26, in resource "snowflake_role_grants" "prod_jaffles_admin":
│ 26: resource "snowflake_role_grants" "prod_jaffles_admin" {
I had to manually created the missing role to progress.
Same issue here.
We are closing this issue as part of a cleanup described in announcement. If you believe that the issue is still valid in v0.89.0, please open a new ticket.