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

Terraform crash with empty spec.backend in appmesh_virtual_node #14040

Closed
mbamber opened this issue Jul 3, 2020 · 6 comments · Fixed by #14074
Closed

Terraform crash with empty spec.backend in appmesh_virtual_node #14040

mbamber opened this issue Jul 3, 2020 · 6 comments · Fixed by #14074
Assignees
Labels
bug Addresses a defect in current functionality. crash Results from or addresses a Terraform crash or kernel panic. service/appmesh Issues and PRs that pertain to the appmesh service.
Milestone

Comments

@mbamber
Copy link
Contributor

mbamber commented Jul 3, 2020

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform Version

Terraform 0.12.2

Affected Resource(s)

  • aws_appmesh_virtual_node

Terraform Configuration Files

resource "aws_appmesh_virtual_node" "main" {
  name      = "example"
  mesh_name = "example"

  spec {
    backend {
      # Add any optional service backends
      dynamic "virtual_service" {
        for_each = var.backends
        content {
          virtual_service_name = virtual_service.value["name"]
        }
      }
    }
}

# var.backends = []

Expected Behavior

Either the node should be created without any backends, or a more descriptive error message should be reported.

Actual Behavior

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

Steps to Reproduce

terraform plan

@ghost ghost added the service/appmesh Issues and PRs that pertain to the appmesh service. label Jul 3, 2020
@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label Jul 3, 2020
@ewbankkit ewbankkit added bug Addresses a defect in current functionality. crash Results from or addresses a Terraform crash or kernel panic. and removed needs-triage Waiting for first response or review from a maintainer. labels Jul 3, 2020
@ewbankkit
Copy link
Contributor

ewbankkit commented Jul 3, 2020

I can reproduce:

resource "aws_appmesh_mesh" "test" {
  name = "test"
}

resource "aws_appmesh_virtual_node" "test" {
  name      = "test"
  mesh_name = aws_appmesh_mesh.test.name

  spec {
    backend {
    }
  }
}
$ terraform apply

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


panic: interface conversion: interface {} is nil, not map[string]interface {}
2020-07-03T09:46:25.776-0400 [DEBUG] plugin.terraform-provider-aws: 
2020-07-03T09:46:25.776-0400 [DEBUG] plugin.terraform-provider-aws: goroutine 63 [running]:
2020-07-03T09:46:25.776-0400 [DEBUG] plugin.terraform-provider-aws: github.com/terraform-providers/terraform-provider-aws/aws.appmeshVirtualNodeBackendHash(0x0, 0x0, 0x1)
2020-07-03T09:46:25.776-0400 [DEBUG] plugin.terraform-provider-aws: 	/home/kit/wrk/src/github.com/terraform-providers/terraform-provider-aws/aws/resource_aws_appmesh_virtual_node.go:445 +0x27e
2020-07-03T09:46:25.776-0400 [DEBUG] plugin.terraform-provider-aws: github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*Set).hash(0xc001a52900, 0x0, 0x0, 0xc0000eec2e, 0x1)
2020-07-03T09:46:25.776-0400 [DEBUG] plugin.terraform-provider-aws: 	/home/kit/wrk/pkg/mod/github.com/hashicorp/terraform-plugin-sdk@v1.14.0/helper/schema/set.go:254 +0x3d
2020-07-03T09:46:25.776-0400 [DEBUG] plugin.terraform-provider-aws: github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*Set).add(0xc001a52900, 0x0, 0x0, 0xc00026e300, 0x0, 0xc001a09db0)
2020-07-03T09:46:25.776-0400 [DEBUG] plugin.terraform-provider-aws: 	/home/kit/wrk/pkg/mod/github.com/hashicorp/terraform-plugin-sdk@v1.14.0/helper/schema/set.go:231 +0x83
2020-07-03T09:46:25.776-0400 [DEBUG] plugin.terraform-provider-aws: github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*ConfigFieldReader).readSet(0xc00130a150, 0xc00130a210, 0x3, 0x3, 0xc00026e3c0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
2020-07-03T09:46:25.776-0400 [DEBUG] plugin.terraform-provider-aws: 	/home/kit/wrk/pkg/mod/github.com/hashicorp/terraform-plugin-sdk@v1.14.0/helper/schema/field_reader_config.go:309 +0x329
2020-07-03T09:46:25.776-0400 [DEBUG] plugin.terraform-provider-aws: github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*ConfigFieldReader).readField(0xc00130a150, 0xc00130a210, 0x3, 0x3, 0xc000534a01, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
2020-07-03T09:46:25.776-0400 [DEBUG] plugin.terraform-provider-aws: 	/home/kit/wrk/pkg/mod/github.com/hashicorp/terraform-plugin-sdk@v1.14.0/helper/schema/field_reader_config.go:132 +0x97f
2020-07-03T09:46:25.776-0400 [DEBUG] plugin.terraform-provider-aws: github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*nestedConfigFieldReader).ReadField(0xc000011f60, 0xc00130a210, 0x3, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc001388400, ...)
2020-07-03T09:46:25.776-0400 [DEBUG] plugin.terraform-provider-aws: 	/home/kit/wrk/pkg/mod/github.com/hashicorp/terraform-plugin-sdk@v1.14.0/helper/schema/field_reader_config.go:352 +0x8e
2020-07-03T09:46:25.776-0400 [DEBUG] plugin.terraform-provider-aws: github.com/hashicorp/terraform-plugin-sdk/helper/schema.readObjectField(0x65813e0, 0xc000011f60, 0xc001a52860, 0x2, 0x2, 0xc0002416b0, 0x0, 0x0, 0x0, 0x0, ...)
2020-07-03T09:46:25.776-0400 [DEBUG] plugin.terraform-provider-aws: 	/home/kit/wrk/pkg/mod/github.com/hashicorp/terraform-plugin-sdk@v1.14.0/helper/schema/field_reader.go:246 +0x1fc
2020-07-03T09:46:25.776-0400 [DEBUG] plugin.terraform-provider-aws: github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*ConfigFieldReader).readField(0xc00130a150, 0xc001a52860, 0x2, 0x2, 0xc000534a01, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
2020-07-03T09:46:25.776-0400 [DEBUG] plugin.terraform-provider-aws: 	/home/kit/wrk/pkg/mod/github.com/hashicorp/terraform-plugin-sdk@v1.14.0/helper/schema/field_reader_config.go:134 +0x8c7
2020-07-03T09:46:25.777-0400 [DEBUG] plugin.terraform-provider-aws: github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*nestedConfigFieldReader).ReadField(0xc000011f50, 0xc001a52860, 0x2, 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
2020-07-03T09:46:25.777-0400 [DEBUG] plugin.terraform-provider-aws: 	/home/kit/wrk/pkg/mod/github.com/hashicorp/terraform-plugin-sdk@v1.14.0/helper/schema/field_reader_config.go:352 +0x8e
2020-07-03T09:46:25.777-0400 [DEBUG] plugin.terraform-provider-aws: github.com/hashicorp/terraform-plugin-sdk/helper/schema.readListField(0x65813e0, 0xc000011f50, 0xc001a0f4e0, 0x1, 0x1, 0xc000270500, 0x0, 0x0, 0x0, 0x0, ...)
2020-07-03T09:46:25.777-0400 [DEBUG] plugin.terraform-provider-aws: 	/home/kit/wrk/pkg/mod/github.com/hashicorp/terraform-plugin-sdk@v1.14.0/helper/schema/field_reader.go:213 +0x340
2020-07-03T09:46:25.777-0400 [DEBUG] plugin.terraform-provider-aws: github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*ConfigFieldReader).readField(0xc00130a150, 0xc001a0f4e0, 0x1, 0x1, 0xc001a52800, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
2020-07-03T09:46:25.777-0400 [DEBUG] plugin.terraform-provider-aws: 	/home/kit/wrk/pkg/mod/github.com/hashicorp/terraform-plugin-sdk@v1.14.0/helper/schema/field_reader_config.go:128 +0x60f
2020-07-03T09:46:25.777-0400 [DEBUG] plugin.terraform-provider-aws: github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*ConfigFieldReader).ReadField(0xc00130a150, 0xc001a0f4e0, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x9adbf40, ...)
2020-07-03T09:46:25.777-0400 [DEBUG] plugin.terraform-provider-aws: 	/home/kit/wrk/pkg/mod/github.com/hashicorp/terraform-plugin-sdk@v1.14.0/helper/schema/field_reader_config.go:28 +0xae
2020-07-03T09:46:25.777-0400 [DEBUG] plugin.terraform-provider-aws: github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*MultiLevelFieldReader).ReadFieldExact(0xc001a527e0, 0xc001a0f4e0, 0x1, 0x1, 0x5bd9408, 0x6, 0x0, 0x0, 0x0, 0x0, ...)
2020-07-03T09:46:25.777-0400 [DEBUG] plugin.terraform-provider-aws: 	/home/kit/wrk/pkg/mod/github.com/hashicorp/terraform-plugin-sdk@v1.14.0/helper/schema/field_reader_multi.go:31 +0xd0
2020-07-03T09:46:25.777-0400 [DEBUG] plugin.terraform-provider-aws: github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*ResourceData).get(0xc0015677a0, 0xc001a0f4e0, 0x1, 0x1, 0x12, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
2020-07-03T09:46:25.777-0400 [DEBUG] plugin.terraform-provider-aws: 	/home/kit/wrk/pkg/mod/github.com/hashicorp/terraform-plugin-sdk@v1.14.0/helper/schema/resource_data.go:532 +0xfa
2020-07-03T09:46:25.777-0400 [DEBUG] plugin.terraform-provider-aws: github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*ResourceData).getChange(0xc0015677a0, 0x5bd73e5, 0x4, 0x1201, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
2020-07-03T09:46:25.777-0400 [DEBUG] plugin.terraform-provider-aws: 	/home/kit/wrk/pkg/mod/github.com/hashicorp/terraform-plugin-sdk@v1.14.0/helper/schema/resource_data.go:508 +0x122
2020-07-03T09:46:25.777-0400 [DEBUG] plugin.terraform-provider-aws: github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*ResourceData).diffChange(0xc0015677a0, 0x5bd73e5, 0x4, 0x21, 0x0, 0x0, 0xc001388fd8, 0x418f0e)
2020-07-03T09:46:25.777-0400 [DEBUG] plugin.terraform-provider-aws: 	/home/kit/wrk/pkg/mod/github.com/hashicorp/terraform-plugin-sdk@v1.14.0/helper/schema/resource_data.go:485 +0x97
2020-07-03T09:46:25.777-0400 [DEBUG] plugin.terraform-provider-aws: github.com/hashicorp/terraform-plugin-sdk/helper/schema.schemaMap.diffList(0xc000241680, 0x5bd73e5, 0x4, 0xc000270500, 0xc001389498, 0x663e020, 0xc0015677a0, 0x42ee00, 0x5cff1b8, 0xc001389498)
2020-07-03T09:46:25.777-0400 [DEBUG] plugin.terraform-provider-aws: 	/home/kit/wrk/pkg/mod/github.com/hashicorp/terraform-plugin-sdk@v1.14.0/helper/schema/schema.go:993 +0x66
2020-07-03T09:46:25.777-0400 [DEBUG] plugin.terraform-provider-aws: github.com/hashicorp/terraform-plugin-sdk/helper/schema.schemaMap.diff(0xc000241680, 0x5bd73e5, 0x4, 0xc000270500, 0xc001a526e0, 0x663e020, 0xc0015677a0, 0xc001389600, 0xd7fcea, 0x6626ca0)
2020-07-03T09:46:25.777-0400 [DEBUG] plugin.terraform-provider-aws: 	/home/kit/wrk/pkg/mod/github.com/hashicorp/terraform-plugin-sdk@v1.14.0/helper/schema/schema.go:954 +0x464
2020-07-03T09:46:25.777-0400 [DEBUG] plugin.terraform-provider-aws: github.com/hashicorp/terraform-plugin-sdk/helper/schema.schemaMap.Diff(0xc000241680, 0xc001a147d0, 0xc001305d40, 0x0, 0x50b8780, 0xc0002de500, 0x0, 0x6626ca0, 0xffffffffffffffff, 0x0)
2020-07-03T09:46:25.778-0400 [DEBUG] plugin.terraform-provider-aws: 	/home/kit/wrk/pkg/mod/github.com/hashicorp/terraform-plugin-sdk@v1.14.0/helper/schema/schema.go:506 +0x215
2020-07-03T09:46:25.778-0400 [DEBUG] plugin.terraform-provider-aws: github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*Resource).simpleDiff(0xc00026c7e0, 0xc001a147d0, 0xc001305d40, 0x50b8780, 0xc0002de500, 0xc001305d01, 0xc001389840, 0x40ef6d)
2020-07-03T09:46:25.778-0400 [DEBUG] plugin.terraform-provider-aws: 	/home/kit/wrk/pkg/mod/github.com/hashicorp/terraform-plugin-sdk@v1.14.0/helper/schema/resource.go:356 +0x85
2020-07-03T09:46:25.778-0400 [DEBUG] plugin.terraform-provider-aws: github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*Provider).SimpleDiff(0xc0000f8180, 0xc001389a28, 0xc001a147d0, 0xc001305d40, 0xc001282b10, 0xc001305d40, 0x0)
2020-07-03T09:46:25.778-0400 [DEBUG] plugin.terraform-provider-aws: 	/home/kit/wrk/pkg/mod/github.com/hashicorp/terraform-plugin-sdk@v1.14.0/helper/schema/provider.go:321 +0x99
2020-07-03T09:46:25.778-0400 [DEBUG] plugin.terraform-provider-aws: github.com/hashicorp/terraform-plugin-sdk/internal/helper/plugin.(*GRPCProviderServer).PlanResourceChange(0xc0001410d8, 0x6625fe0, 0xc001282ae0, 0xc0015676c0, 0xc0001410d8, 0xc001282ae0, 0xc000c6bb30)
2020-07-03T09:46:25.778-0400 [DEBUG] plugin.terraform-provider-aws: 	/home/kit/wrk/pkg/mod/github.com/hashicorp/terraform-plugin-sdk@v1.14.0/internal/helper/plugin/grpc_provider.go:633 +0x793
2020-07-03T09:46:25.778-0400 [DEBUG] plugin.terraform-provider-aws: github.com/hashicorp/terraform-plugin-sdk/internal/tfplugin5._Provider_PlanResourceChange_Handler(0x5a8ebe0, 0xc0001410d8, 0x6625fe0, 0xc001282ae0, 0xc001925bc0, 0x0, 0x6625fe0, 0xc001282ae0, 0xc001926480, 0x16f)
2020-07-03T09:46:25.778-0400 [DEBUG] plugin.terraform-provider-aws: 	/home/kit/wrk/pkg/mod/github.com/hashicorp/terraform-plugin-sdk@v1.14.0/internal/tfplugin5/tfplugin5.pb.go:3287 +0x217
2020-07-03T09:46:25.778-0400 [DEBUG] plugin.terraform-provider-aws: google.golang.org/grpc.(*Server).processUnaryRPC(0xc000be9c80, 0x664a5c0, 0xc000ee2900, 0xc00014cf00, 0xc000ac4cf0, 0x9ab03a8, 0x0, 0x0, 0x0)
2020-07-03T09:46:25.778-0400 [DEBUG] plugin.terraform-provider-aws: 	/home/kit/wrk/pkg/mod/google.golang.org/grpc@v1.27.1/server.go:1024 +0x4f4
2020-07-03T09:46:25.778-0400 [DEBUG] plugin.terraform-provider-aws: google.golang.org/grpc.(*Server).handleStream(0xc000be9c80, 0x664a5c0, 0xc000ee2900, 0xc00014cf00, 0x0)
2020-07-03T09:46:25.778-0400 [DEBUG] plugin.terraform-provider-aws: 	/home/kit/wrk/pkg/mod/google.golang.org/grpc@v1.27.1/server.go:1313 +0xd97
2020-07-03T09:46:25.778-0400 [DEBUG] plugin.terraform-provider-aws: google.golang.org/grpc.(*Server).serveStreams.func1.1(0xc000ab01a0, 0xc000be9c80, 0x664a5c0, 0xc000ee2900, 0xc00014cf00)
2020-07-03T09:46:25.778-0400 [DEBUG] plugin.terraform-provider-aws: 	/home/kit/wrk/pkg/mod/google.golang.org/grpc@v1.27.1/server.go:722 +0xbb
2020-07-03T09:46:25.778-0400 [DEBUG] plugin.terraform-provider-aws: created by google.golang.org/grpc.(*Server).serveStreams.func1
2020-07-03T09:46:25.778-0400 [DEBUG] plugin.terraform-provider-aws: 	/home/kit/wrk/pkg/mod/google.golang.org/grpc@v1.27.1/server.go:720 +0xa1
2020-07-03T09:46:25.784-0400 [DEBUG] plugin: plugin process exited: path=/home/kit/wrk/bin/terraform-provider-aws pid=12763 error="exit status 2"
2020/07/03 09:46:25 [ERROR] <root>: eval: *terraform.EvalDiff, err: rpc error: code = Unavailable desc = transport is closing
2020/07/03 09:46:25 [ERROR] <root>: eval: *terraform.EvalSequence, err: rpc error: code = Unavailable desc = transport is closing
2020/07/03 09:46:25 [TRACE] [walkPlan] Exiting eval tree: aws_appmesh_virtual_node.main
2020/07/03 09:46:25 [TRACE] vertex "aws_appmesh_virtual_node.main": visit complete
2020/07/03 09:46:25 [TRACE] vertex "aws_appmesh_virtual_node.main": dynamic subgraph encountered errors
2020/07/03 09:46:25 [TRACE] vertex "aws_appmesh_virtual_node.main": visit complete
2020/07/03 09:46:25 [TRACE] dag/walk: upstream of "meta.count-boundary (EachMode fixup)" errored, so skipping
2020-07-03T09:46:25.785-0400 [WARN]  plugin.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = transport is closing"
2020/07/03 09:46:25 [TRACE] dag/walk: upstream of "provider.aws (close)" errored, so skipping
2020/07/03 09:46:25 [TRACE] dag/walk: upstream of "root" errored, so skipping
2020/07/03 09:46:25 [TRACE] statemgr.Filesystem: removing lock metadata file .terraform.tfstate.lock.info
2020/07/03 09:46:25 [TRACE] statemgr.Filesystem: unlocking terraform.tfstate using fcntl flock
2020-07-03T09:46:25.786-0400 [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 !!!!!!!!!!!!!!!!!!!!!!!!!!!!

Relevant code:

https://github.com/terraform-providers/terraform-provider-aws/blob/9900515b28b413505e5dd7c8d8ea258c59515f32/aws/resource_aws_appmesh_virtual_node.go#L443-L453

@ewbankkit
Copy link
Contributor

@mbamber Rather than allow empty backend blocks I think the best solution here is to make virtual_service required.
Your code will then need to change to

resource "aws_appmesh_virtual_node" "main" {
 name      = "example"
 mesh_name = "example"

 spec {
   # Add any optional service backends
   dynamic "backend" {
     for_each = local.backends
     content {
       virtual_service {
         virtual_service_name = virtual_service.value["name"]
       }
     }
   }
 }
}

@mbamber
Copy link
Contributor Author

mbamber commented Jul 7, 2020

That makes sense to me 👍

@bflad
Copy link
Contributor

bflad commented Aug 21, 2020

The fix for this has been merged and will release with version 3.4.0 of the Terraform AWS Provider, later next week. Thanks to @ewbankkit for the implementation. 👍

@ghost
Copy link

ghost commented Aug 27, 2020

This has been released in version 3.4.0 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template for triage. Thanks!

@ghost
Copy link

ghost commented Sep 21, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Sep 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. crash Results from or addresses a Terraform crash or kernel panic. service/appmesh Issues and PRs that pertain to the appmesh service.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants