terraform-provider-snowflake: data_retention_time_in_days = 0 must be defined in snowflake_database from share
Terraform CLI and Provider Versions
Provider version: 0.85.0
Terraform Configuration
resource "snowflake_database" "from_share" {
for_each = var.databases_from_share
name = upper(each.key)
# data_retention_time_in_days = 0
from_share = {
provider = upper(each.value.from_share.provider)
share = upper(each.value.from_share.share)
}
}
Expected Behavior
After successfully creating the database from share I can add other resources and apply the changes.
Actual Behavior
After successfully creating the database from share I cannot add other resources and apply the changes.
all successive applies try to set data_retention_time_in_days = 1:
Terraform will perform the following actions:
# snowflake_database.from_share["my_share"] will be updated in-place
~ resource "snowflake_database" "from_share" {
~ data_retention_time_in_days = 0 -> 1
id = "MY_SHARE"
name = "MY_SHARE"
# (2 unchanged attributes hidden)
}
...
snowflake_database.from_share["my_share"]: Modifying... [id=MY_SHARE]
╷
│ Error: error updating database data retention time on MY_SHARE err = 003001 (42501): SQL access control error:
│ Insufficient privileges to operate on database 'MY_SHARE'
│
│ with snowflake_database.from_share["my_share"],
│ on snowflake_shares.tf line 1, in resource "snowflake_database" "from_share":
│ 1: resource "snowflake_database" "from_share" {
│
Adding data_retention_time_in_days = 0 to the database definition fixes this: Terraform doesn’t detect any changes in the database from share
Steps to Reproduce
terraform applywithoutdata_retention_time_in_daysterraform applyanother time: the second time terraform want to setdata_retention_time_in_days = 0 -> 1
How much impact is this issue causing?
Medium
Logs
No response
Additional Information
No response
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 22
Hi @sfc-gh-jcieslak , I will close this issue. Thanks!
@sfc-gh-jcieslak this is the creation statement that is created by version 0.87 of the provider:
CREATE DATABASE "MYSHARE" FROM SHARE "PROVIDER.SHARE"."SHARED_SCHEMA";It should be:CREATE DATABASE "MYSHARE" FROM SHARE "PROVIDER"."SHARE"."SHARED_SCHEMA";Ok, I didn’t analyze it in-depth, but this looks like it’s related to this issue - https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/2356. So, the issue may be happening, because there’s a default value set on
data_retention_time_in_days(set to1). When it’s not set in the config and remotely it’s set to something different than 1, Terraform tries to set it back to 1 (because that’s the default). I’m working on a change right now that will remove the default, so after a merge and release it should work as intended. As you already pointed out the workaround is to set it explicitly to 0.