-
Notifications
You must be signed in to change notification settings - Fork 427
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provider evaluates _ and % as wildcards in table and pipe names #1241
Comments
you could use INFORMATION_SCHEMA.TABLES for most of the table parameters. however, that table does not contain information about change tracking which is a option you can enable in snowflake_table resource. |
same with INFORMATION_SCHEMA.PIPES, it does not include integration and error integration fields. |
I have the same issue with the resource |
This same issue affects role grants (and, it seems, most objects):
I suspect the appropriate fix would be to escape all wildcard characters every time this provider executes a command like A minimal example which fails for me: terraform {
required_providers {
snowflake = {
source = "Snowflake-Labs/snowflake"
version = "~> 0.61"
account = "<account-locator>"
}
}
required_version = ">= 1.0"
}
# Snowflake provider for managing grants to roles.
provider "snowflake" {
account = local.account
role = "SECURITYADMIN"
}
# These two roles look the same to the provider!
resource "snowflake_role" "tester" {
name = "TESTER"
}
resource "snowflake_role" "test_r" {
name = "TEST_R"
}
resource "snowflake_role_grants" "test_r_to_securityadmin" {
role_name = snowflake_role.test_r.name
roles = ["SECURITYADMIN"]
}
resource "snowflake_role_grants" "tester_to_securityadmin" {
role_name = snowflake_role.tester.name
roles = ["SECURITYADMIN"]
} The above errors with:
|
Provider Version
0.40.0
Terraform Version
1.2.9
Describe the bug
When there are two (or more) tables or pipes (maybe some other objects too?) which have a similar kind of name with underscores or % in their name, the initial creation of the tables works ok but on the subsequent run the plan wants to replace the second one of them with the details of the other one.
Example with tables:
/SCMTMS/D_SF_DOC
/SCMTMS/D_SFIDOC
When evaluating the plan against state after the initial run, Terraform queries the related object using a syntax like:
Below is result from a query taken from query history when the plan is being evaluated against the state for table /SCMTMS/D_SF_DOC:
Below is the result from a query taken from query history when the plan is being evaluated against the state for table /SCMTMS/D_SFIDOC:
Because _ works as a wildcard for any character, the provider takes the first result when evaluating against the state and in this case it is wrong as it happens to be the first one in the list.
Expected behavior
When there are tables with underscores or other wildcard characters like % in their name, they should be treated accordingly and not use these characters in the table name as wildcards.
Code samples and commands
Example snippet, iterator loops through this with local.sf_object_name_evaluation.table_name evaluating to /SCMTMS/D_SF_DOC and /SCMTMS/D_SFIDOC (some info redacted or changed):
Example snippet from terraform plan on the after the initial run (some info redacted or changed):
Additional context
Table name cannot be compromised in this case as we are trying to automate the creation hundreds of staging tables using TF.
One option which comes to mind is to change the provider to utilize INFORMATION_SCHEMA.TABLES|PIPES|etc to get the same info as with SHOW TABLES|PIPES|etc.
The text was updated successfully, but these errors were encountered: