mongodb / terraform-provider-mongodbatlas

Terraform MongoDB Atlas Provider: Deploy, update, and manage MongoDB Atlas infrastructure as code through HashiCorp Terraform
https://registry.terraform.io/providers/mongodb/mongodbatlas
Mozilla Public License 2.0
242 stars 168 forks source link

panic: runtime error: index out of range #1

Closed arthurio closed 5 years ago

arthurio commented 5 years ago

Hi!

I started creating my resources using the mongodb repo, I was on commit https://github.com/terraform-providers/terraform-provider-mongodbatlas/commit/2b90e034de74f0fcf864c950c53a9233d687182c. I switched to this "official" provider and now I'm getting the following when trying to plan:

panic: runtime error: index out of range
2019-08-22T00:28:01.827-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4: 
2019-08-22T00:28:01.827-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4: goroutine 81 [running]:
2019-08-22T00:28:01.827-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4: github.com/terraform-providers/terraform-provider-mongodbatlas/mongodbatlas.decodeStateID(0xc00064a130, 0xb, 0x1)
2019-08-22T00:28:01.827-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-mongodbatlas/mongodbatlas/provider.go:96 +0x235
2019-08-22T00:28:01.827-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4: github.com/terraform-providers/terraform-provider-mongodbatlas/mongodbatlas.resourceMongoDBAtlasProjectIPWhitelistRead(0xc0002e64d0, 0x1b3d640, 0xc0002ea540, 0xc0002e64d0, 0x0)
2019-08-22T00:28:01.827-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-mongodbatlas/mongodbatlas/resource_mongodbatlas_project_ip_whitelist.go:127 +0x80
2019-08-22T00:28:01.827-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4: github.com/terraform-providers/terraform-provider-mongodbatlas/vendor/github.com/hashicorp/terraform/helper/schema.(*Resource).RefreshWithoutUpgrade(0xc0002c9800, 0xc0002206e0, 0x1b3d640, 0xc0002ea540, 0xc00014d890, 0xc0002206e0, 0x0)
2019-08-22T00:28:01.827-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-mongodbatlas/vendor/github.com/hashicorp/terraform/helper/schema/resource.go:447 +0x119
2019-08-22T00:28:01.827-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4: github.com/terraform-providers/terraform-provider-mongodbatlas/vendor/github.com/hashicorp/terraform/helper/plugin.(*GRPCProviderServer).ReadResource(0xc00000e4f0, 0x1eacb60, 0xc00014d470, 0xc0000dba00, 0xc00000e4f0, 0xc00014d470, 0xc0002f1bd0)
2019-08-22T00:28:01.827-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-mongodbatlas/vendor/github.com/hashicorp/terraform/helper/plugin/grpc_provider.go:496 +0x334
2019-08-22T00:28:01.827-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4: github.com/terraform-providers/terraform-provider-mongodbatlas/vendor/github.com/hashicorp/terraform/internal/tfplugin5._Provider_ReadResource_Handler(0x1c1ec60, 0xc00000e4f0, 0x1eacb60, 0xc00014d470, 0xc0002205a0, 0x0, 0x1eacb60, 0xc00014d470, 0xc000228150, 0x66)
2019-08-22T00:28:01.827-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-mongodbatlas/vendor/github.com/hashicorp/terraform/internal/tfplugin5/tfplugin5.pb.go:2983 +0x23e
2019-08-22T00:28:01.827-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4: github.com/terraform-providers/terraform-provider-mongodbatlas/vendor/google.golang.org/grpc.(*Server).processUnaryRPC(0xc000556600, 0x1eb7d60, 0xc000556d80, 0xc00039c000, 0xc0000987e0, 0x2795850, 0x0, 0x0, 0x0)
2019-08-22T00:28:01.827-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-mongodbatlas/vendor/google.golang.org/grpc/server.go:966 +0x470
2019-08-22T00:28:01.827-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4: github.com/terraform-providers/terraform-provider-mongodbatlas/vendor/google.golang.org/grpc.(*Server).handleStream(0xc000556600, 0x1eb7d60, 0xc000556d80, 0xc00039c000, 0x0)
2019-08-22T00:28:01.827-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-mongodbatlas/vendor/google.golang.org/grpc/server.go:1245 +0xd25
2019-08-22T00:28:01.827-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4: github.com/terraform-providers/terraform-provider-mongodbatlas/vendor/google.golang.org/grpc.(*Server).serveStreams.func1.1(0xc00003c2d0, 0xc000556600, 0x1eb7d60, 0xc000556d80, 0xc00039c000)
2019-08-22T00:28:01.827-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-mongodbatlas/vendor/google.golang.org/grpc/server.go:685 +0x9f
2019-08-22T00:28:01.827-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4: created by github.com/terraform-providers/terraform-provider-mongodbatlas/vendor/google.golang.org/grpc.(*Server).serveStreams.func1
2019-08-22T00:28:01.827-0700 [DEBUG] plugin.terraform-provider-mongodbatlas_v0.1.0_x4:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-mongodbatlas/vendor/google.golang.org/grpc/server.go:683 +0xa1
2019/08/22 00:28:01 [ERROR] module.sle_development: eval: *terraform.EvalRefresh, err: rpc error: code = Unavailable desc = transport is closing
2019/08/22 00:28:01 [ERROR] module.sle_development: eval: *terraform.EvalSequence, err: rpc error: code = Unavailable desc = transport is closing
2019/08/22 00:28:01 [TRACE] [walkRefresh] Exiting eval tree: module.sle_development.mongodbatlas_project_ip_whitelist.vpc
2019/08/22 00:28:01 [TRACE] vertex "module.sle_development.mongodbatlas_project_ip_whitelist.vpc": visit complete
2019/08/22 00:28:01 [TRACE] vertex "module.sle_development.mongodbatlas_project_ip_whitelist.vpc": dynamic subgraph encountered errors
2019/08/22 00:28:01 [TRACE] vertex "module.sle_development.mongodbatlas_project_ip_whitelist.vpc": visit complete
2019/08/22 00:28:01 [TRACE] module.sle_development: eval: *terraform.EvalSequence
2019/08/22 00:28:01 [TRACE] module.sle_development: eval: *terraform.EvalGetProvider
2019/08/22 00:28:01 [TRACE] module.sle_development: eval: *terraform.EvalReadState
2019/08/22 00:28:01 [TRACE] EvalReadState: reading state for module.sle_development.mongodbatlas_cluster.sle
2019/08/22 00:28:01 [TRACE] UpgradeResourceState: schema version of module.sle_development.mongodbatlas_cluster.sle is still 0; calling provider "mongodbatlas" for any other minor fixups
2019/08/22 00:28:01 [TRACE] GRPCProvider: UpgradeResourceState
2019/08/22 00:28:01 [ERROR] module.sle_development: eval: *terraform.EvalReadState, err: rpc error: code = Unavailable desc = all SubConns are in TransientFailure, latest connection error: <nil>
2019/08/22 00:28:01 [ERROR] module.sle_development: eval: *terraform.EvalSequence, err: rpc error: code = Unavailable desc = all SubConns are in TransientFailure, latest connection error: <nil>
2019/08/22 00:28:01 [TRACE] [walkRefresh] Exiting eval tree: module.sle_development.mongodbatlas_cluster.sle
2019/08/22 00:28:01 [TRACE] vertex "module.sle_development.mongodbatlas_cluster.sle": visit complete
2019/08/22 00:28:01 [TRACE] vertex "module.sle_development.mongodbatlas_cluster.sle": dynamic subgraph encountered errors
2019/08/22 00:28:01 [TRACE] vertex "module.sle_development.mongodbatlas_cluster.sle": visit complete
2019/08/22 00:28:01 [TRACE] module.sle_production: eval: *terraform.EvalSequence
2019/08/22 00:28:01 [TRACE] module.sle_production: eval: *terraform.EvalOpFilter
2019/08/22 00:28:01 [TRACE] module.sle_production: eval: *terraform.EvalWriteOutput
2019/08/22 00:28:01 [TRACE] dag/walk: upstream of "module.sle_development.mongodbatlas_network_container.sle" errored, so skipping
2019/08/22 00:28:01 [TRACE] dag/walk: upstream of "module.sle_development.output.collaboration_db_url" errored, so skipping
2019/08/22 00:28:01 [TRACE] dag/walk: upstream of "module.sle_development.mongodbatlas_network_peering.vpc" errored, so skipping
2019/08/22 00:28:01 [TRACE] dag/walk: upstream of "module.sle_development.mongodbatlas_database_user.sle" errored, so skipping
2019/08/22 00:28:01 [TRACE] dag/walk: upstream of "output.collaboration_db_url_development" errored, so skipping
2019/08/22 00:28:01 [TRACE] dag/walk: upstream of "module.sle_development.provider.mongodbatlas (close)" errored, so skipping
2019/08/22 00:28:01 [TRACE] dag/walk: upstream of "module.sle_development.aws_vpc_peering_connection_accepter.vpc" errored, so skipping
2019/08/22 00:28:01 [TRACE] dag/walk: upstream of "module.sle_development.aws_route.mongodb" errored, so skipping

Did you make breaking changes? Should I delete my state and re-import my resources?

marinsalinas commented 5 years ago

Hello @arthurio, could you try to delete the state file and re-import your resources?

PacoDw commented 5 years ago

Hello @arthurio, If despite re-import your resources the problem continues can you share us your Terraform configuration omitting sensible data?

arthurio commented 5 years ago

I used terraform state rm ... to remove all my states and re-imported the resources. Everything worked except the mongodbatlas_project_ip_whitelist. The doc's example is unclear... terraform import mongodbatlas_project_ip_whitelist.test cHJvamVjdF9pZA==:NWNmNWE0NWE5Y2NmNjQwMGU2MDk4MWI2-ZW50cmllcw== so project_id:xxxx encoded in base64? I tried but it gave me an error: Error: error getting project IP whitelist information: whiteListEntry is invalid because must be set

I tried:

Where xxxxx is my actual project id but no luck...

PacoDw commented 5 years ago

The problem with whitelist is resolved on issue 42 in mongo repository (https://github.com/mongodb/terraform-provider-mongodbatlas/pull/42) but is not merged yet here, we are waiting for that as soon as posible.

arthurio commented 5 years ago

And where can I get or generate the id for import (cHJvamVjdF9pZA==:NWNmNWE0NWE5Y2NmNjQwMGU2MDk4MWI2-ZW50cmllcw==)?

arthurio commented 5 years ago

Ohh I think you pointed to the wrong PR... https://github.com/mongodb/terraform-provider-mongodbatlas/pull/39 is the one :)

PacoDw commented 5 years ago

I’m sorry for that, I misunderstood because both pr pointed to the withelist resource.

arthurio commented 5 years ago

Ok, so after using your branch, I was able to import back my resources. However, I had to manually tweak the state to:

Hope this helps.