terraform-provider-snowflake
terraform-provider-snowflake copied to clipboard
Schema scan for snowflake views with same names in single database produce wrong state file and cyclic changes
Terraform CLI and Provider Versions
Terraform CLI = 1.5.0 Snowflake Provider = 0.85.0
Terraform Configuration
resource "snowflake_database" "this" {
name = "SCHEMA_ISSUE_TEST"
data_retention_time_in_days = 1
}
resource "snowflake_schema" "test_az" {
database = snowflake_database.this.name
name = "TEST_SCHEMA_AZ"
data_retention_days = 1
}
resource "snowflake_schema" "test_bz" {
database = snowflake_database.this.name
name = "TEST_SCHEMA_BZ"
data_retention_days = 1
}
resource "snowflake_view" "a" {
database = snowflake_database.this.name
schema = snowflake_schema.test_az.name
name = "TEST_TABLE"
statement = <<-SQL
select 1 as A from dual
SQL
or_replace = true
is_secure = false
}
resource "snowflake_view" "b" {
database = snowflake_database.this.name
schema = snowflake_schema.test_bz.name
name = "TEST_TABLE"
statement = <<-SQL
select 1 as A from dual
SQL
or_replace = true
is_secure = false
}
Expected Behavior
Two views are created inside Snowflake and the next Plan will show no further applies. Schema references are handled correctly even if there are views with the same name in one database in different schemas.
Actual Behavior
Even if the correct schema is mentioned in the state file terraform thinks that the view "b" is in the a-schema because of a failure during the Snowflake Metadata Scan. I tested the same terraform code in version 0.84.1 and there the scan of the views is currently still correct. Here you can see the changes in the Snowflake Query History.
Correct version 0.84.1:
Wrong version 0.85.0:
Steps to Reproduce
terraform applyterraform apply
How much impact is this issue causing?
High
Logs
No response
Additional Information
Please provide a rough estimation when this behaviour will be changed because it makes the version 0.85.0 unusable for our envrionemnts.
Hey @JESCHO99. Thanks for reaching out to us.
We are aware that some resources behave this way and we have this fix planned for all affected resources in the upcoming weeks. I will solve the Views one now, so there's a high probability it will be released with today's release.
@sfc-gh-asawicki thanks for your fast reply. But I wonder why we were not able to find this issue in the issue list of the GitHub Repo for the 0.85.0 version. If you are aware of this behaviour which has effect on basic ressources like views could you try to make this visible in the repository? Because the anaylsis of this issues when upgrading the versions of the provider took us quite some time. If you make this visible we would know where to pay attention.
@JESCHO99 Currently, the issues visible on GH are the issues created by the community only. We have a much longer internal backlog, that is not yet shared through GH. We are slowly progressing with improving the transparency and visibility; that's why we shared recently our high-level roadmap (https://github.com/Snowflake-Labs/terraform-provider-snowflake/blob/main/ROADMAP.md#our-roadmap), state of the SDK rewrite in the README, etc.
I agree with you, though, that bigger known issues should be listed on the repository level (and in the official docs) and we have that as one of the items planned for the next weeks.
@JESCHO99 we released the fix as part of 0.86.0 release. Could you please check if this solves the issue for you?
Closing the issue. Please create a new one if the issue persists in the newest provider version.