Snowflake-Labs / terraform-provider-snowflake

Terraform provider for managing Snowflake accounts
https://registry.terraform.io/providers/Snowflake-Labs/snowflake/latest
MIT License
545 stars 419 forks source link

The terraform-provider-snowflake_v0.71.0 plugin crashed - user creation. #2070

Closed thomasyu888 closed 8 months ago

thomasyu888 commented 1 year ago

Provider Version

Terraform cloud v1.5.7

Terraform Version

v0.71.0

Describe the bug

Stack trace from the terraform-provider-snowflake_v0.71.0 plugin:

panic: interface conversion: sdk.ObjectIdentifier is sdk.SchemaObjectIdentifier, not sdk.AccountObjectIdentifier

goroutine 96 [running]:
github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/resources.ReadUser(0xc0009f7480, {0x1ac3660?, 0xc000b4ab60?})
github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/resources/user.go:244 +0x96a
github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/resources.CreateUser(0x0?, {0x1ac3660?, 0xc000b4ab60?})
github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/resources/user.go:236 +0xbc8
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).create(0x1ddd1a0?, {0x1ddd1a0?, 0xc0002e5b60?}, 0xd?, {0x1ac3660?, 0xc000b4ab60?})
github.com/hashicorp/terraform-plugin-sdk/v2@v2.26.1/helper/schema/resource.go:695 +0x178
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0xc00063dea0, {0x1ddd1a0, 0xc0002e5b60}, 0xc0001f92b0, 0xc0009f7300, {0x1ac3660, 0xc000b4ab60})
github.com/hashicorp/terraform-plugin-sdk/v2@v2.26.1/helper/schema/resource.go:837 +0xa85
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0xc0009b3c50, {0x1ddd1a0?, 0xc0002e5a40?}, 0xc0002ea0f0)
github.com/hashicorp/terraform-plugin-sdk/v2@v2.26.1/helper/schema/grpc_provider.go:1021 +0xe8d
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ApplyResourceChange(0xc00027f040, {0x1ddd1a0?, 0xc0002e5050?}, 0xc000b3a2a0)
github.com/hashicorp/terraform-plugin-go@v0.14.3/tfprotov5/tf5server/server.go:818 +0x574
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ApplyResourceChange_Handler({0x1a75c80?, 0xc00027f040}, {0x1ddd1a0, 0xc0002e5050}, 0xc000b3a230, 0x0)
github.com/hashicorp/terraform-plugin-go@v0.14.3/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:385 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0xc0007fcb40, {0x1decb60, 0xc000581860}, 0xc0009ee240, 0xc0009bd4a0, 0x2a34400, 0x0)
google.golang.org/grpc@v1.53.0/server.go:1336 +0xd33
google.golang.org/grpc.(*Server).handleStream(0xc0007fcb40, {0x1decb60, 0xc000581860}, 0xc0009ee240, 0x0)
google.golang.org/grpc@v1.53.0/server.go:1704 +0xa36
google.golang.org/grpc.(*Server).serveStreams.func1.2()
google.golang.org/grpc@v1.53.0/server.go:965 +0x98
created by google.golang.org/grpc.(*Server).serveStreams.func1
google.golang.org/grpc@v1.53.0/server.go:963 +0x28a

Error: The terraform-provider-snowflake_v0.71.0 plugin crashed!

This is always indicative of a bug within the plugin. It would be immensely
helpful if you could report the crash with the plugin's maintainers so that it
can be fixed. The output above should help diagnose the issue.

Expected behavior

The plugin failing on terraform cloud, but the user was created

Code samples and commands

....

provider "snowflake" {
  account = var.snowflake_account
  username = var.snowflake_user
  password = var.snowflake_pwd
  role = "SYSADMIN"
}

provider "snowflake" {
  alias = "useradmin"
  account = var.snowflake_account
  username = var.snowflake_user
  password = var.snowflake_pwd
  role = "USERADMIN"
}

resource "snowflake_user" "user" {
  provider = snowflake.useradmin
  name         = "user@..."
  login_name   = "user@..."
}
thomasyu888 commented 1 year ago

This seems to be a duplicate of https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/2058 . I used an older version as well and it worked

sfc-gh-asawicki commented 10 months ago

Hey @thomasyu888. Thanks for creating the issue.

Can you confirm that the solution described in #2058 works for you? Do you see this error in the newest provider version?

sfc-gh-asawicki commented 9 months ago

@thomasyu888, do you have any updates?

thomasyu888 commented 9 months ago

Hi @sfc-gh-asawicki ,

Thanks for providing an update - I will try to take a look soon.

sfc-gh-asawicki commented 8 months ago

Hey @thomasyu888, I will close this issue; please open a new one if you are experiencing this problem in the more recent versions of the provider.

thomasyu888 commented 8 months ago

Thanks! Sorry about the delays - I haven't been able to test this, but will open a ticket if needed