Skip to content
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

snowflake_object_parameter resource for the key "DATA_RETENTION_TIME_IN_DAYS" is not working as expected #1938

Closed
Bharath-Kumar-RNDC opened this issue Jul 10, 2023 · 9 comments · Fixed by #2029
Labels
bug Used to mark issues with provider's incorrect behavior

Comments

@Bharath-Kumar-RNDC
Copy link

Bharath-Kumar-RNDC commented Jul 10, 2023

Provider Version
0.68.1

The provider version you are using.
0.68.1

Terraform Version
1.5.2

The version of Terraform you were using when the bug was encountered.
1.5.2

Describe the bug
The documentation says that the data_retention_days argument is deprecated for Snowflake tables. When I use the data_retention_days argument under a table resource, Terraform tells me to use the snowflake_object_parameter resource instead. When I used the snowflake_object_parameter resource, using "DATA_RETENTION_TIME_IN_DAYS" as the key and set the value to 30 and run terraform apply, the data retention time for the table will be set to 30. But if I make changes to the table schema or any other snowflake resources, the data retention time for the table reverts back to 1 (which is the default value for Snowflake time travel)

Expected behavior
When I used the snowflake_object_parameter resource, using "DATA_RETENTION_TIME_IN_DAYS" as the key and set the value to 30 and run terraform apply, the data retention time for the table will be set to 30. If I make changes to the table schema or any other snowflake resources, the data retention time for the table should be 30.

A clear and concise description of what you expected to happen.
When I used the snowflake_object_parameter resource, using "DATA_RETENTION_TIME_IN_DAYS" as the key and set the value to 30 and run terraform apply, the data retention time for the table will be set to 30. If I make changes to the table schema or any other snowflake resources, the data retention time for the table should be 30.

Code samples and commands

Step-1:
create a table called "SALES"

resource "snowflake_table" "sales_t" {
database = "TF_DEMO"
schema = "SALES"
name = "SALES"

column {
name = "ID"
type = "NUMBER(38,0)"
}

column {
name = "SALE_NAME"
type = "VARCHAR(10)"
}
}

run below commands to create the above table
terraform init
terraform validate
terraform plan
terraform apply

at this point, data_retention_time of the table is 1 which is the default value.

Step - 2:
change data_retention_time of the table

resource "snowflake_object_parameter" "data_retention_time" {
key = "DATA_RETENTION_TIME_IN_DAYS"
value = "30"
object_type = "TABLE"
object_identifier {
database = "TF_DEMO"
schema = "SALES"
name = "SALES"
}
}

run below commands to change the data_retention_time
terraform init
terraform validate
terraform plan
terraform apply

Now, data_retention_time of the table will be changes to 30 which is correct.

Step-3:
create a new table called "BOOKS"

resource "snowflake_table" "book" {
database = "TF_DEMO"
schema = "SALES"
name = "BOOKS"

column {
name = "ID"
type = "NUMBER(38,0)"
}

column {
name = "BOOK_NAME"
type = "VARCHAR(10)"
}
}

run below commands to create an another table.
terraform init
terraform validate
terraform plan
terraform apply

this is where things get weird. If I check the data_retention_time of the table (SALES) which was created earlier, the value will be changed to 1. This is not the intended behaviour.

@Bharath-Kumar-RNDC Bharath-Kumar-RNDC added the bug Used to mark issues with provider's incorrect behavior label Jul 10, 2023
@sfc-gh-swinkler
Copy link
Collaborator

@Bharath-Kumar-RNDC I think it was a mistake on our part to mark data_retention_days for the snowflake_table object as deprecated. I don't see why we should not support both ways of setting object parameters. However, it should be renamed to data_retention_time_in_days for consistency. @sfc-gh-pbosak - since you are working on this table resource already, could you please do this?

Using both the table resource and the snowflake_object_parameter resource is expected to cause conflicts since they are trying to manage the same attribute. Although, in this case, it is clearly a bug.

@sfc-gh-pbosak
Copy link
Contributor

Yes, I can

@Bharath-Kumar-RNDC
Copy link
Author

@sfc-gh-swinkler Thanks for your response. If this bug is fixed, it solves a big problem for us. Is there any eta on fixing this bug. @sfc-gh-pbosak once this change is done, could you please post a comment here?

@sfc-gh-pbosak
Copy link
Contributor

Will do

@Bharath-Kumar-RNDC
Copy link
Author

the bug ( conflict between data_retention_days table resource parameter and the snowflake_object_parameter resource) will also be fixed along with the parameter name change, am I correct?

@Bharath-Kumar-RNDC
Copy link
Author

@sfc-gh-swinkler @sfc-gh-pbosak any updates on this issue?

@sfc-gh-tiversen
Copy link

Hi @sfc-gh-swinkler , I just received a messsage from a customer in Norway stating that this still does not work

@sfc-gh-asawicki
Copy link
Collaborator

@sfc-gh-tiversen please create a new issue with a proper description, provider version used, example config, and reproduction steps.

@Petruspop
Copy link

@sfc-gh-asawicki @sfc-gh-tiversen
Hi, so I am the customer, and I feel I am lost in a loop here.
Support verified (tested) that this is still a defect, and referred me to this case on github, which says it is solved.

So perhaps Snowflake support, development and product management can talk here? Without the need of us providing more details?
https://app.snowflake.com/support/case/00658127

The issue we reported in early December is that Snowsight and the Terraform provider has different behaviour.
If you omit the data retention days parameter in Snowsight the parameter is inherited, if you do the same with Terraform provider a default setting is used, and the parameter is not inherited as expected.

Thanks!
Peter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Used to mark issues with provider's incorrect behavior
Projects
None yet
6 participants