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_account apply fails with index out of range panic #1671

Closed
matthewoflynn-dxrx opened this issue Mar 28, 2023 · 2 comments
Closed
Labels
bug Used to mark issues with provider's incorrect behavior category:resource resource:account Issue connected to the snowflake_account resource

Comments

@matthewoflynn-dxrx
Copy link

Provider Version

Installed snowflake-labs/snowflake v0.59.0 (signed by a HashiCorp partner, key ID 5166D7352E69A585)

Terraform Version

v1.3.6

Describe the bug

  1. Attempted to use the snowflake_account resource.
  2. Initially, I ran into unable to scan row for SHOW ORGANIZATION ACCOUNTS #1606. I used the suggested workaround of disabling latest behaviour change bundle.
  3. terraform apply on below configuration.
  4. snowflake provider prints an error and exits (full output below).
  5. The snowflake account has been created and the admin user can log in but the admin user must change their password even though must_change_password = false.

Expected behavior

The terraform apply to successfully complete and the admin user to not have to change their password.

Code samples and commands

Sample config:

provider "snowflake" {
  alias = "orgadmin"

  account  = ...
  username = ...
  password = ...

  role = "ORGADMIN"
}


resource "snowflake_account" "this" {
  provider             = snowflake.orgadmin

  name                 = "snow"
  admin_name           = "terraform"
  admin_password       = random_password.admin_password.result
  email                = "[email protected]"
  must_change_password = false
  edition              = "BUSINESS_CRITICAL"
  comment              = "account managed by terraform"
  region               = "AWS_US_EAST_1"
}


resource "random_password" "admin_password" {
  length  = 30
  special = false
}

After running apply, I got the following output:

Terraform will perform the following actions:

  # snowflake_account.this will be created
  + resource "snowflake_account" "this" {
      + admin_name           = "terraform"
      + admin_password       = (sensitive value)
      + comment              = "account managed by terraform"
      + edition              = "BUSINESS_CRITICAL"
      + email                = "<redacted>"
      + first_name           = "<redacted>"
      + id                   = (known after apply)
      + last_name            = "<redacted>"
      + must_change_password = false
      + name                 = "<redacted>"
      + region               = "AWS_US_EAST_1"
    }

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

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

snowflake_account.this: Creating...
snowflake_account.this: Still creating... [10s elapsed]
╷
│ Error: Request cancelled
│
│   with snowflake_account.this,
│   on main.tf line 6, in resource "snowflake_account" "this":
│    6: resource "snowflake_account" "this" {
│
│ The plugin.(*GRPCProvider).ApplyResourceChange request was cancelled.
╵

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

panic: runtime error: index out of range [0] with length 0

goroutine 38 [running]:
github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/snowflake.ShowAccount(0x1ef6d00?, {0xc0002cf130, 0xf})
	github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/snowflake/account.go:199 +0x457
github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/snowflake.(*AccountBuilder).Create(0xc0008fcda0)
	github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/snowflake/account.go:147 +0x10c5
github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/resources.CreateAccount(0x0?, {0x1ed6660?, 0xc0005c9380})
	github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/resources/account.go:265 +0x4ad
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).create(0x2141ac0?, {0x2141ac0?, 0xc0008d47b0?}, 0xd?, {0x1ed6660?, 0xc0005c9380?})
	github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:695 +0x178
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0xc000496000, {0x2141ac0, 0xc0008d47b0}, 0xc000717d40, 0xc0008acb80, {0x1ed6660, 0xc0005c9380})
	github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:837 +0xa85
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0xc000472420, {0x2141ac0?, 0xc0008d4690?}, 0xc0008aa910)
	github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/grpc_provider.go:1021 +0xe8d
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ApplyResourceChange(0xc0000012c0, {0x2141ac0?, 0xc0008a7c80?}, 0xc0008a5650)
	github.com/hashicorp/[email protected]/tfprotov5/tf5server/server.go:818 +0x574
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ApplyResourceChange_Handler({0x1ea2d40?, 0xc0000012c0}, {0x2141ac0, 0xc0008a7c80}, 0xc0008a55e0, 0x0)
	github.com/hashicorp/[email protected]/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:385 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0xc000484000, {0x2147700, 0xc0005829c0}, 0xc0007190e0, 0xc0007474d0, 0x28dc3c0, 0x0)
	google.golang.org/[email protected]/server.go:1336 +0xd23
google.golang.org/grpc.(*Server).handleStream(0xc000484000, {0x2147700, 0xc0005829c0}, 0xc0007190e0, 0x0)
	google.golang.org/[email protected]/server.go:1704 +0xa2f
google.golang.org/grpc.(*Server).serveStreams.func1.2()
	google.golang.org/[email protected]/server.go:965 +0x98
created by google.golang.org/grpc.(*Server).serveStreams.func1
	google.golang.org/[email protected]/server.go:963 +0x28a

Error: The terraform-provider-snowflake_v0.59.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.

Additional context

The snowflake account has been created and the admin user can log in but the admin user must change their password even though must_change_password = false.

@matthewoflynn-dxrx matthewoflynn-dxrx added the bug Used to mark issues with provider's incorrect behavior label Mar 28, 2023
@sfc-gh-jcieslak sfc-gh-jcieslak added category:resource resource:account Issue connected to the snowflake_account resource labels May 20, 2024
@sfc-gh-jcieslak
Copy link
Collaborator

Hello 👋
Recently, we released v0.100.0 and v1.0.0 that contains reworked account resource. The issue should not happen there, please migrate with the use of migration guide and let us know if the issue can be closed. Thank You :)

@sfc-gh-jcieslak
Copy link
Collaborator

Closing due to long inactivity. The new fixed account resource was released in the versions mentioned above.

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 Issue connected to the snowflake_account resource
Projects
None yet
Development

No branches or pull requests

2 participants