aidanmelen / terraform-provider-snowsql

Terraform SnowSQL provider
https://registry.terraform.io/providers/aidanmelen/snowsql/latest
Other
22 stars 10 forks source link

bug: The `snowsql_query` data source ID will is always reset even if it has already been set before. #86

Closed aidanmelen closed 1 year ago

aidanmelen commented 1 year ago

The snowsql_query data source ID will is always reset even if it has already been set before when the name argument is not specified.

Terraform Version

Run terraform -v to show the version. If you are not running the latest version of Terraform, please upgrade because your issue may have already been fixed.

Affected Resource(s)

Please list the resources as a list, for example:

If this issue appears to affect multiple resources, it may be an issue with Terraform's core, so please mention this.

Terraform Configuration Files

data "snowsql_query" "select_current_user" {
  statements = "SELECT current_user()"
}

Debug Output

$ TF_LOG=debug terraform apply
...
2023-02-24T12:34:39.536-0700 [WARN]  Provider "provider[\"registry.terraform.io/aidanmelen/snowsql\"]" produced an unexpected new value for data.snowsql_query.select_current_user.
      - .id: was cty.StringVal("cfsh2finv5cve7d955og"), but now cty.StringVal("cfsh2jqnv5cvvltgp2t0")
...

Expected Behavior

during the first terraform apply, the data source ID should be set in state. Then all subsequent applies should use this ID.

Actual Behavior

The data source ID always gets reset when the name argument is not specified.

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. TF_LOG=debug terraform apply
  2. TF_LOG=debug terraform apply and we should see the data source ID change in state.
aidanmelen commented 1 year ago

There doesn't seem like an easy way to fix this other than just explicitly setting the name. Moreover, this is only visible when running with TF_LOG=debug