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

SQL Compilation Error While Deleting a snowflake_account_parameter Resource. #1679

Open
DustinMoriarty opened this issue Mar 30, 2023 · 2 comments · May be fixed by #3108
Open

SQL Compilation Error While Deleting a snowflake_account_parameter Resource. #1679

DustinMoriarty opened this issue Mar 30, 2023 · 2 comments · May be fixed by #3108
Labels
bug Used to mark issues with provider's incorrect behavior category:resource resource:account_parameter Issue connected to the snowflake_account_parameter resource

Comments

@DustinMoriarty
Copy link

Provider Version

0.59.0

Terraform Version

1.4.2

Describe the bug

I am trying to delete a snowflake_account_parameter resource. However, a SQL compilation error occurs. What is even more challenging is that I was not able to consistently reproduce this behavior in another environment. Note the ALTER ACCOUNT SET = <nil> in the logs. It looks like the SQL compiler is not handling a null value correctly.

Terraform plan:

Terraform will perform the following actions:

  # snowflake_account_parameter.id_token will be destroyed
  # (because snowflake_account_parameter.id_token is not in configuration)
  - resource "snowflake_account_parameter" "id_token" {
      - id    = "ALLOW_ID_TOKEN" -> null
      - value = "true" -> null
    }

Plan: 0 to add, 0 to change, 1 to destroy.

Relevant logs:

2023-03-30T13:44:05.108-0500 [INFO]  provider.terraform-provider-snowflake_v0.59.0: 2023/03/30 13:44:05 [DEBUG] sql-conn-exec [query ALTER ACCOUNT SET  = <nil> err 001003 (42000): SQL compilation error: syntax error line 1 at position 19 unexpected '='. duration 210.276125ms args {}]: timestamp=2023-03-30T13:44:05.107-0500
2023-03-30T13:44:05.108-0500 [ERROR] provider.terraform-provider-snowflake_v0.59.0: Response contains error diagnostic: diagnostic_detail= diagnostic_severity=ERROR diagnostic_summary="error creating account parameter err = 001003 (42000): SQL compilation error:
syntax error line 1 at position 19 unexpected '='." tf_provider_addr=registry.terraform.io/Snowflake-Labs/snowflake @caller=github.com/hashicorp/[email protected]/tfprotov5/internal/diag/diagnostics.go:55 tf_resource_type=snowflake_account_parameter tf_rpc=ApplyResourceChange @module=sdk.proto tf_proto_version=5.3 tf_req_id=a3f1b89d-f0d8-2a89-c4c5-49fffff2ff8b timestamp=2023-03-30T13:44:05.108-0500
2023-03-30T13:44:05.108-0500 [ERROR] vertex "snowflake_account_parameter.id_token (destroy)" error: error creating account parameter err = 001003 (42000): SQL compilation error:
syntax error line 1 at position 19 unexpected '='.
2023-03-30T13:44:05.108-0500 [DEBUG] states/remote: state read serial is: 128; serial is: 128
2023-03-30T13:44:05.108-0500 [DEBUG] states/remote: state read lineage is: 229406d1-8859-0190-f1a8-c02ac1494355; lineage is: 229406d1-8859-0190-f1a8-c02ac1494355
╷
│ Error: error creating account parameter err = 001003 (42000): SQL compilation error:
│ syntax error line 1 at position 19 unexpected '='.
│ 
│ 

Expected behavior

The resource is removed from the terraform state and the parameter is set to it's default value.

Code samples and commands

terraform apply

Additional context

I had originally imported this resource which had been manually created. I was trying to delete it and recreate it because it was causing a persistent difference, which is an additional problem.

@DustinMoriarty DustinMoriarty added the bug Used to mark issues with provider's incorrect behavior label Mar 30, 2023
@DustinMoriarty
Copy link
Author

Here is how to reproduce the issue.

The problem arrises from importing an existing snowflake_account_parameter resource into terraform.

terraform {
  required_version = ">=1.4.5,<1.5"
  required_providers {
    snowflake = {
      source  = "Snowflake-Labs/snowflake"
      version = ">=0.61.0,<0.62"
    }
  }
}

provider "snowflake" {
  role = "accountadmin"
}

resource "snowflake_account_parameter" "allow_id_token" {
  key = "ALLOW_ID_TOKEN"
  value = true
}

Shell script.

set -x
export TF_CLI_ARGS='-no-color'
terraform init -reconfigure -upgrade
terraform apply -auto-approve
terraform state rm snowflake_account_parameter.allow_id_token
terraform import snowflake_account_parameter.allow_id_token "ALLOW_ID_TOKEN"
export TF_LOG=DEBUG
terraform apply -auto-approve

Note that this is case number 00504646 within snowflake support.

@DustinMoriarty
Copy link
Author

Also, note that the error occurs just for regular terraform apply. A deletion does not even have to occur.

@sfc-gh-jcieslak sfc-gh-jcieslak added category:resource resource:account_parameter Issue connected to the snowflake_account_parameter resource labels May 20, 2024
Richard-Barrett added a commit to Richard-Barrett/terraform-provider-snowflake that referenced this issue Oct 1, 2024
@Richard-Barrett Richard-Barrett linked a pull request Oct 1, 2024 that will close this issue
2 tasks
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:resource resource:account_parameter Issue connected to the snowflake_account_parameter resource
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants