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

[Bug]: Grace Period should NOT be mandatory - Unable to import existing accounts #3390

Open
1 task
sivadotblog opened this issue Feb 10, 2025 · 1 comment
Open
1 task
Labels
bug Used to mark issues with provider's incorrect behavior category:stable Topics connected with stable features resource:account Issue connected to the snowflake_account resource

Comments

@sivadotblog
Copy link

Terraform CLI Version

1.6.0

Terraform Provider Version

1.0.3

Company Name

Humana

Terraform Configuration

Terraform Configuration*
 
# Complete (with SERVICE user type)
resource "snowflake_account" "account" {
 
  name                 = var.account_name
  admin_name           = var.admin_name
  admin_rsa_public_key = tls_private_key.rsa.public_key_pem
  admin_user_type      = "SERVICE"
  email                = var.account_email
  edition              = var.edition
  region_group         = "PUBLIC"
  region               = var.snowflake_region
  comment              = "built by Terraform"
  is_org_admin         = var.is_org_admin
  grace_period_in_days = 90
 
  depends_on = [tls_private_key.rsa]
}
 
import {
  to = resource.snowflake_account.account
  id = "XXX.AZ_SNOWFLAKE_CENTERWELL_EASTUS2_SBX"
}

Category

category:resource

Object type(s)

No response

Expected Behavior

Expected Behavior*
I expect the account to be successfully imported into terraform state

Actual Behavior*
get the following error when trying to import

Error: 001817 (42601): SQL compilation error:
│ parameter value out of range: GRACE_PERIOD_IN_DAYS. Must be between 3 and 90.

run the code

Actual Behavior

account imported successfully

Steps to Reproduce

Steps to Reproduce*
create a snowflake account manually
copy the hcl configuration
update the account name in import

How much impact is this issue causing?

Low

Logs

No response

Additional Information

From: Support [support@snowflake.com]
Sent: 1/30/2025 1:37 PM

Hello Pradeep,

Thank you for writing back.

Indeed there is no parameter ‘grace_period_in_days’, from Snowflake, it can be set only with DROP statement.

However, a possible reason why you receive the below error;

Error: 001817 (42601): SQL compilation error:
? parameter value out of range: GRACE_PERIOD_IN_DAYS. Must be between 3 and 90.

Is because when you created a Snowflake account using Terraform you did not specify ‘grace_period_in_days’ (0/null) / or specified a different number.

When you then attempted to update the account name in import script with ‘grace_period_in_days’ as 90, the ‘grace_period_in_days’ value mismatched the previous value set (either a null value/some value) when creating the account.

We have ruled out any issue from Snowflake side, since Terraform Provider is not part of the Snowflake Service and Snowflake Support does not handle technical issues or feature requests related to this application’s functionality, I’d request you to please reach out to your Accounts team/Terraform support.

Kind Regards,
Nikita
Snowflake Inc.

Would you like to implement a fix?

  • Yeah, I'll take it 😎
@sivadotblog sivadotblog added the bug Used to mark issues with provider's incorrect behavior label Feb 10, 2025
@sfc-gh-jmichalak
Copy link
Collaborator

Hi @sivadotblog 👋

It looks like some field triggered the recreation of the resource during the import (was this intended?). Then, Terraform considers config and state empty during the import, and when deleting the object, grace_period_days is also empty (i.e., =0).

This happens on a changed field with ForceNew because the terraform config differs from the actual state (during import) of such a field. Probably executing DROP during the import is not intended.

  • please send logs with TF_LOG=DEBUG, so we can see what the plan looks like,
  • you can use ignore_changes to ignore changes on the problematic field,
  • you can use prevent_destroy to prevent accidentally deleting the entire account (such plans will simply fail).

On our side, we can set a "default" value for the grace period so that this operation succeeds even for empty configs or states.

@sfc-gh-jmichalak sfc-gh-jmichalak added resource:account Issue connected to the snowflake_account resource category:stable Topics connected with stable features labels Feb 12, 2025
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 category:stable Topics connected with stable features resource:account Issue connected to the snowflake_account resource
Projects
None yet
Development

No branches or pull requests

2 participants