Skip to content

Malformed import command panics with "runtime error: index out of range [1] with length 1" #72

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

Closed
soulshake opened this issue Jan 28, 2021 · 0 comments

Comments

@soulshake
Copy link

$ terraform import 'module.eks_projects.module.cluster.module.cluster_services.kustomization_resource.current["rbac.authorization.k8s.io_v1_ClusterRole|~X|fluentd-role"]' fluentd-role

module.eks_projects.module.cluster.module.cluster_services.kustomization_resource.current["rbac.authorization.k8s.io_v1_ClusterRole|~X|fluentd-role"]: Importing from ID "fluentd-role"...

Error: rpc error: code = Unavailable desc = transport is closing

panic: runtime error: index out of range [1] with length 1
Traceback
panic: runtime error: index out of range [1] with length 1
2021-01-28T18:44:47.913Z [DEBUG] plugin.terraform-provider-kustomization_v0.3.0: 
2021-01-28T18:44:47.913Z [DEBUG] plugin.terraform-provider-kustomization_v0.3.0: goroutine 81 [running]:
2021-01-28T18:44:47.913Z [DEBUG] plugin.terraform-provider-kustomization_v0.3.0: sigs.k8s.io/kustomize/api/resid.GvkFromString(0xc000384660, 0xc, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
2021-01-28T18:44:47.913Z [DEBUG] plugin.terraform-provider-kustomization_v0.3.0: 	sigs.k8s.io/kustomize/[email protected]/resid/gvk.go:43 +0x1c7
2021-01-28T18:44:47.913Z [DEBUG] plugin.terraform-provider-kustomization_v0.3.0: sigs.k8s.io/kustomize/api/resid.FromString(0xc000384660, 0xc, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
2021-01-28T18:44:47.913Z [DEBUG] plugin.terraform-provider-kustomization_v0.3.0: 	sigs.k8s.io/kustomize/[email protected]/resid/resid.go:65 +0xcb
2021-01-28T18:44:47.913Z [DEBUG] plugin.terraform-provider-kustomization_v0.3.0: github.com/kbst/terraform-provider-kustomize/kustomize.kustomizationResourceImport(0xc000462310, 0x1bf5b40, 0xc0005ae2a0, 0x16, 0xc000723c28, 0xc000080c01, 0x0, 0x3)
2021-01-28T18:44:47.913Z [DEBUG] plugin.terraform-provider-kustomization_v0.3.0: 	github.com/kbst/terraform-provider-kustomize/kustomize/resource_kustomization.go:434 +0xd7
2021-01-28T18:44:47.913Z [DEBUG] plugin.terraform-provider-kustomization_v0.3.0: github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*Provider).ImportState(0xc0001a0400, 0xc000649af8, 0xc000384660, 0xc, 0x8a9c45, 0xc000a92060, 0x26, 0x26, 0x1eb6620)
2021-01-28T18:44:47.913Z [DEBUG] plugin.terraform-provider-kustomization_v0.3.0: 	github.com/hashicorp/[email protected]/helper/schema/provider.go:390 +0x286
2021-01-28T18:44:47.913Z [DEBUG] plugin.terraform-provider-kustomization_v0.3.0: github.com/hashicorp/terraform-plugin-sdk/internal/helper/plugin.(*GRPCProviderServer).ImportResourceState(0xc00011ab60, 0x22c8b20, 0xc0009ee1b0, 0xc000062980, 0xc00011ab60, 0xc0009ee1b0, 0xc000642ba0)
2021-01-28T18:44:47.913Z [DEBUG] plugin.terraform-provider-kustomization_v0.3.0: 	github.com/hashicorp/[email protected]/internal/helper/plugin/grpc_provider.go:953 +0xcb
2021-01-28T18:44:47.913Z [DEBUG] plugin.terraform-provider-kustomization_v0.3.0: github.com/hashicorp/terraform-plugin-sdk/internal/tfplugin5._Provider_ImportResourceState_Handler(0x1f2df00, 0xc00011ab60, 0x22c8b20, 0xc0009ee1b0, 0xc0009ea180, 0x0, 0x22c8b20, 0xc0009ee1b0, 0xc000a92060, 0x26)
2021-01-28T18:44:47.913Z [DEBUG] plugin.terraform-provider-kustomization_v0.3.0: 	github.com/hashicorp/[email protected]/internal/tfplugin5/tfplugin5.pb.go:3323 +0x214
2021-01-28T18:44:47.913Z [DEBUG] plugin.terraform-provider-kustomization_v0.3.0: google.golang.org/grpc.(*Server).processUnaryRPC(0xc000138540, 0x22e28c0, 0xc000103c80, 0xc000128300, 0xc000388930, 0x2fd17d8, 0x0, 0x0, 0x0)
2021-01-28T18:44:47.913Z [DEBUG] plugin.terraform-provider-kustomization_v0.3.0: 	google.golang.org/[email protected]/server.go:1171 +0x522
2021-01-28T18:44:47.913Z [DEBUG] plugin.terraform-provider-kustomization_v0.3.0: google.golang.org/grpc.(*Server).handleStream(0xc000138540, 0x22e28c0, 0xc000103c80, 0xc000128300, 0x0)
2021-01-28T18:44:47.913Z [DEBUG] plugin.terraform-provider-kustomization_v0.3.0: 	google.golang.org/[email protected]/server.go:1494 +0xcc5
2021-01-28T18:44:47.913Z [DEBUG] plugin.terraform-provider-kustomization_v0.3.0: google.golang.org/grpc.(*Server).serveStreams.func1.2(0xc00050c000, 0xc000138540, 0x22e28c0, 0xc000103c80, 0xc000128300)
2021-01-28T18:44:47.913Z [DEBUG] plugin.terraform-provider-kustomization_v0.3.0: 	google.golang.org/[email protected]/server.go:834 +0xa5
2021-01-28T18:44:47.913Z [DEBUG] plugin.terraform-provider-kustomization_v0.3.0: created by google.golang.org/grpc.(*Server).serveStreams.func1
2021-01-28T18:44:47.913Z [DEBUG] plugin.terraform-provider-kustomization_v0.3.0: 	google.golang.org/[email protected]/server.go:832 +0x1fd
2021-01-28T18:44:47.915Z [DEBUG] plugin: plugin process exited: path=.terraform/providers/registry.terraform.io/kbst/kustomization/0.3.0/linux_amd64/terraform-provider-kustomization_v0.3.0 pid=10422 error="exit status 2"
2021/01/28 18:44:47 [TRACE] vertex "module.eks_projects.module.cluster.module.cluster_services.kustomization_resource.current[\"rbac.authorization.k8s.io_v1_ClusterRole|~X|fluentd-role\"] (import id \"fluentd-role\")": visit complete
2021-01-28T18:44:47.915Z [WARN]  plugin.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = transport is closing"
2021/01/28 18:44:47 [TRACE] dag/walk: upstream of "module.eks_projects.module.cluster.module.cluster_services (close)" errored, so skipping
2021/01/28 18:44:47 [TRACE] dag/walk: upstream of "module.eks_projects.module.cluster.module.cluster_services.provider[\"registry.terraform.io/kbst/kustomization\"] (close)" errored, so skipping
2021/01/28 18:44:47 [TRACE] No provider meta schema returned
2021/01/28 18:44:47 [TRACE] GRPCProvider: Configure
2021-01-28T18:44:47.938Z [DEBUG] plugin.terraform-provider-kubernetes_v1.12.0_x4: 2021/01/28 18:44:47 [INFO] Successfully initialized config
2021/01/28 18:44:47 [TRACE] vertex "module.eks_projects.module.cluster.provider[\"registry.terraform.io/hashicorp/kubernetes\"].eks": visit complete
2021/01/28 18:44:47 [TRACE] dag/walk: upstream of "module.eks_projects.module.cluster.kubernetes_service.current" errored, so skipping
2021/01/28 18:44:47 [TRACE] dag/walk: visiting "module.eks_projects.module.cluster.kubernetes_config_map.current"
2021/01/28 18:44:47 [TRACE] vertex "module.eks_projects.module.cluster.kubernetes_config_map.current": starting visit (*terraform.NodeAbstractResource)
2021/01/28 18:44:47 [TRACE] dag/walk: upstream of "module.eks_projects.module.cluster.aws_route53_record.wildcard" errored, so skipping
2021/01/28 18:44:47 [TRACE] vertex "module.eks_projects.module.cluster.kubernetes_config_map.current": visit complete
2021/01/28 18:44:47 [TRACE] dag/walk: upstream of "module.eks_projects.module.cluster.aws_route53_record.host" errored, so skipping
2021/01/28 18:44:47 [TRACE] dag/walk: upstream of "module.eks_projects.module.cluster.provider[\"registry.terraform.io/hashicorp/kubernetes\"].eks (close)" errored, so skipping
2021/01/28 18:44:47 [TRACE] dag/walk: visiting "module.eks_projects.module.cluster.module.node_pool.var.depends-on-aws-auth (expand)"
2021/01/28 18:44:47 [TRACE] vertex "module.eks_projects.module.cluster.module.node_pool.var.depends-on-aws-auth (expand)": starting visit (*terraform.nodeExpandModuleVariable)
2021/01/28 18:44:47 [TRACE] vertex "module.eks_projects.module.cluster.module.node_pool.var.depends-on-aws-auth (expand)": expanding dynamic subgraph
2021/01/28 18:44:47 [TRACE] vertex "module.eks_projects.module.cluster.module.node_pool.var.depends-on-aws-auth (expand)": entering dynamic subgraph
2021/01/28 18:44:47 [TRACE] dag/walk: visiting "module.eks_projects.module.cluster.module.node_pool.var.depends-on-aws-auth"
2021/01/28 18:44:47 [TRACE] vertex "module.eks_projects.module.cluster.module.node_pool.var.depends-on-aws-auth": starting visit (*terraform.nodeModuleVariable)
2021/01/28 18:44:47 [TRACE] evalVariableValidations: not active for module.eks_projects.module.cluster.module.node_pool.var.depends-on-aws-auth, so skipping
2021/01/28 18:44:47 [TRACE] vertex "module.eks_projects.module.cluster.module.node_pool.var.depends-on-aws-auth": visit complete
2021/01/28 18:44:47 [TRACE] vertex "module.eks_projects.module.cluster.module.node_pool.var.depends-on-aws-auth (expand)": dynamic subgraph completed successfully
2021/01/28 18:44:47 [TRACE] vertex "module.eks_projects.module.cluster.module.node_pool.var.depends-on-aws-auth (expand)": visit complete
2021/01/28 18:44:47 [TRACE] dag/walk: visiting "module.eks_projects.module.cluster.module.node_pool.aws_eks_node_group.nodes"
2021/01/28 18:44:47 [TRACE] vertex "module.eks_projects.module.cluster.module.node_pool.aws_eks_node_group.nodes": starting visit (*terraform.NodeAbstractResource)
2021/01/28 18:44:47 [TRACE] vertex "module.eks_projects.module.cluster.module.node_pool.aws_eks_node_group.nodes": visit complete
2021/01/28 18:44:47 [TRACE] dag/walk: visiting "module.eks_projects.module.cluster.module.node_pool (close)"
2021/01/28 18:44:47 [TRACE] vertex "module.eks_projects.module.cluster.module.node_pool (close)": starting visit (*terraform.nodeCloseModule)
2021/01/28 18:44:47 [TRACE] vertex "module.eks_projects.module.cluster.module.node_pool (close)": visit complete
2021/01/28 18:44:47 [TRACE] dag/walk: upstream of "provider[\"registry.terraform.io/hashicorp/aws\"] (close)" errored, so skipping
2021/01/28 18:44:47 [TRACE] dag/walk: upstream of "module.eks_projects.module.cluster (close)" errored, so skipping
2021/01/28 18:44:47 [TRACE] dag/walk: upstream of "module.eks_projects (close)" errored, so skipping
2021/01/28 18:44:47 [TRACE] dag/walk: upstream of "root" errored, so skipping
2021-01-28T18:44:47.939Z [DEBUG] plugin: plugin exited
2021-01-28T18:44:47.941Z [DEBUG] plugin: plugin process exited: path=.terraform/providers/registry.terraform.io/hashicorp/kubernetes/1.12.0/linux_amd64/terraform-provider-kubernetes_v1.12.0_x4 pid=10409
2021-01-28T18:44:47.941Z [WARN]  plugin.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = transport is closing"
2021-01-28T18:44:47.941Z [DEBUG] plugin: plugin exited
2021-01-28T18:44:47.943Z [DEBUG] plugin: plugin process exited: path=.terraform/providers/registry.terraform.io/hashicorp/aws/3.9.0/linux_amd64/terraform-provider-aws_v3.9.0_x5 pid=10370
2021-01-28T18:44:47.943Z [DEBUG] plugin: plugin exited



!!!!!!!!!!!!!!!!!!!!!!!!!!! TERRAFORM CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!

Terraform crashed! This is always indicative of a bug within Terraform.
A crash log has been placed at "crash.log" relative to your current
working directory. It would be immensely helpful if you could please
report the crash with Terraform[1] so that we can fix this.

When reporting bugs, please include your terraform version. That
information is available on the first line of crash.log. You can also
get it by running 'terraform --version' on the command line.

SECURITY WARNING: the "crash.log" file that was created may contain 
sensitive information that must be redacted before it is safe to share 
on the issue tracker.

[1]: https://github.com/hashicorp/terraform/issues

!!!!!!!!!!!!!!!!!!!!!!!!!!! TERRAFORM CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!

Of course the correct command works:
terraform import 'module.eks_projects.module.cluster.module.cluster_services.kustomization_resource.current["rbac.authorization.k8s.io_v1_ClusterRole|~X|fluentd-role"]' 'rbac.authorization.k8s.io_v1_ClusterRole|~X|fluentd-role'

But perhaps a crash could be avoided.

@pst pst closed this as completed in 79dfbcd Jan 29, 2021
pst added a commit that referenced this issue Jan 29, 2021
Prevent panic when user specifies invalid ID during import fix #72
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant