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

aws_network_interface: nil pointer dereference panic when flattening attachment #15567

Merged

Conversation

essien-cobham
Copy link
Contributor

Added nil checks on network interface attachment id/device index

Community Note

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment 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 pull request followers and do not help prioritize the request

Relates OR Closes #0000

Release note for CHANGELOG:

Fixed nil pointer dereference panics when network interface attachment device index or id is missing in data source

Output from acceptance testing:

$ make testacc TESTARGS='-run=TestAccXXX'

...

Added nil checks on network interface attachment id/device index
@essien-cobham essien-cobham requested a review from a team October 9, 2020 00:22
@ghost ghost added the size/XS Managed by automation to categorize the size of a PR. label Oct 9, 2020
@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label Oct 9, 2020
@essien-cobham
Copy link
Contributor Author

I attempted to use the "aws_network_interface" data source in my Terraform configuration and got back the following error message:

panic: runtime error: invalid memory address or nil pointer dereference 2020-10-08T19:14:08.709-0400 [DEBUG] plugin.terraform-provider-aws_v3.9.0_x5: [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x39e2429] 2020-10-08T19:14:08.709-0400 [DEBUG] plugin.terraform-provider-aws_v3.9.0_x5: 2020-10-08T19:14:08.709-0400 [DEBUG] plugin.terraform-provider-aws_v3.9.0_x5: goroutine 102 [running]: 2020-10-08T19:14:08.709-0400 [DEBUG] plugin.terraform-provider-aws_v3.9.0_x5: github.com/terraform-providers/terraform-provider-aws/aws.flattenAttachment(...) 2020-10-08T19:14:08.709-0400 [DEBUG] plugin.terraform-provider-aws_v3.9.0_x5: /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-aws/aws/structure.go:1131 2020-10-08T19:14:08.709-0400 [DEBUG] plugin.terraform-provider-aws_v3.9.0_x5: github.com/terraform-providers/terraform-provider-aws/aws.dataSourceAwsNetworkInterfaceRead(0xc001dcc800, 0x504ad80, 0xc0019bb180, 0x9b80a90, 0x5d25330) 2020-10-08T19:14:08.709-0400 [DEBUG] plugin.terraform-provider-aws_v3.9.0_x5: /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-aws/aws/data_source_aws_network_interface.go:173 +0x879 2020-10-08T19:14:08.709-0400 [DEBUG] plugin.terraform-provider-aws_v3.9.0_x5: github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).read(0xc000172e70, 0x670fe40, 0xc001d89e40, 0xc001dcc800, 0x504ad80, 0xc0019bb180, 0x0, 0x0, 0x0) 2020-10-08T19:14:08.709-0400 [DEBUG] plugin.terraform-provider-aws_v3.9.0_x5: /opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:281 +0x88 2020-10-08T19:14:08.709-0400 [DEBUG] plugin.terraform-provider-aws_v3.9.0_x5: github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).ReadDataApply(0xc000172e70, 0x670fe40, 0xc001d89e40, 0xc001de9d40, 0x504ad80, 0xc0019bb180, 0xc0019bb180, 0xc001de9d40, 0x0, 0x0) 2020-10-08T19:14:08.709-0400 [DEBUG] plugin.terraform-provider-aws_v3.9.0_x5: /opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:489 +0xff 2020-10-08T19:14:08.709-0400 [DEBUG] plugin.terraform-provider-aws_v3.9.0_x5: github.com/hashicorp/terraform-plugin-sdk/v2/internal/helper/plugin.(*GRPCProviderServer).ReadDataSource(0xc000cbf5c0, 0x670fe40, 0xc001d89e40, 0xc001d89e00, 0xc000cbf5c0, 0xc000cbf5d0, 0x5d25320) 2020-10-08T19:14:08.709-0400 [DEBUG] plugin.terraform-provider-aws_v3.9.0_x5: /opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/[email protected]/internal/helper/plugin/grpc_provider.go:1102 +0x4c5 2020-10-08T19:14:08.709-0400 [DEBUG] plugin.terraform-provider-aws_v3.9.0_x5: github.com/hashicorp/terraform-plugin-sdk/v2/internal/tfplugin5._Provider_ReadDataSource_Handler.func1(0x670fe40, 0xc001d89e40, 0x598c140, 0xc001d89e00, 0xc001d89e40, 0x51c4380, 0x63a2e3b, 0x0) 2020-10-08T19:14:08.709-0400 [DEBUG] plugin.terraform-provider-aws_v3.9.0_x5: /opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/[email protected]/internal/tfplugin5/tfplugin5.pb.go:3348 +0x86 2020-10-08T19:14:08.709-0400 [DEBUG] plugin.terraform-provider-aws_v3.9.0_x5: github.com/hashicorp/terraform-plugin-sdk/v2/plugin.Serve.func3.1(0x670ff00, 0xc000fdc630, 0x598c140, 0xc001d89e00, 0xc001de9980, 0xc001de99a0, 0xc000dc8ba0, 0x49266d, 0x5845780, 0xc000fdc630) 2020-10-08T19:14:08.709-0400 [DEBUG] plugin.terraform-provider-aws_v3.9.0_x5: /opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/[email protected]/plugin/serve.go:76 +0x87 2020-10-08T19:14:08.709-0400 [DEBUG] plugin.terraform-provider-aws_v3.9.0_x5: github.com/hashicorp/terraform-plugin-sdk/v2/internal/tfplugin5._Provider_ReadDataSource_Handler(0x5abcfc0, 0xc000cbf5c0, 0x670ff00, 0xc000fdc630, 0xc001dfaea0, 0xc0012f1880, 0x670ff00, 0xc000fdc630, 0xc001de6500, 0x126) 2020-10-08T19:14:08.709-0400 [DEBUG] plugin.terraform-provider-aws_v3.9.0_x5: /opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/[email protected]/internal/tfplugin5/tfplugin5.pb.go:3350 +0x14b 2020-10-08T19:14:08.709-0400 [DEBUG] plugin.terraform-provider-aws_v3.9.0_x5: google.golang.org/grpc.(*Server).processUnaryRPC(0xc000d04700, 0x6731b20, 0xc001334f00, 0xc001c1b500, 0xc000b0d3e0, 0x9b46150, 0x0, 0x0, 0x0) 2020-10-08T19:14:08.709-0400 [DEBUG] plugin.terraform-provider-aws_v3.9.0_x5: /opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/google.golang.org/[email protected]/server.go:1171 +0x50a 2020-10-08T19:14:08.709-0400 [DEBUG] plugin.terraform-provider-aws_v3.9.0_x5: google.golang.org/grpc.(*Server).handleStream(0xc000d04700, 0x6731b20, 0xc001334f00, 0xc001c1b500, 0x0) 2020-10-08T19:14:08.709-0400 [DEBUG] plugin.terraform-provider-aws_v3.9.0_x5: /opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/google.golang.org/[email protected]/server.go:1494 +0xccd 2020-10-08T19:14:08.709-0400 [DEBUG] plugin.terraform-provider-aws_v3.9.0_x5: google.golang.org/grpc.(*Server).serveStreams.func1.2(0xc000a36000, 0xc000d04700, 0x6731b20, 0xc001334f00, 0xc001c1b500) 2020-10-08T19:14:08.709-0400 [DEBUG] plugin.terraform-provider-aws_v3.9.0_x5: /opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/google.golang.org/[email protected]/server.go:834 +0xa1 2020-10-08T19:14:08.709-0400 [DEBUG] plugin.terraform-provider-aws_v3.9.0_x5: created by google.golang.org/grpc.(*Server).serveStreams.func1 2020-10-08T19:14:08.709-0400 [DEBUG] plugin.terraform-provider-aws_v3.9.0_x5: /opt/teamcity-agent/work/5d79fe75d4460a2f/pkg/mod/google.golang.org/[email protected]/server.go:832 +0x204 2020/10/08 19:14:08 [ERROR] eval: *terraform.evalReadDataRefresh, err: rpc error: code = Unavailable desc = transport is closing 2020/10/08 19:14:08 [ERROR] eval: *terraform.EvalSequence, err: rpc error: code = Unavailable desc = transport is closing

There are nil checks in other similar code blocks in the file but there were none present in the lines I changed. I've hard-coded the ENI IDs in my configuration for the time being.

@bflad bflad added bug Addresses a defect in current functionality. crash Results from or addresses a Terraform crash or kernel panic. service/ec2 Issues and PRs that pertain to the ec2 service. and removed needs-triage Waiting for first response or review from a maintainer. labels Nov 9, 2020
@bflad bflad self-assigned this Nov 9, 2020
@bflad bflad added this to the v3.15.0 milestone Nov 9, 2020
Copy link
Contributor

@bflad bflad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks for this fix, @essien-cobham 🚀

Output from acceptance testing:

--- PASS: TestAccAWSENI_attached (116.76s)
--- PASS: TestAccAWSENI_basic (67.56s)
--- PASS: TestAccAWSENI_computedIPs (70.13s)
--- PASS: TestAccAWSENI_disappears (66.23s)
--- PASS: TestAccAWSENI_ignoreExternalAttachment (132.24s)
--- PASS: TestAccAWSENI_ipv6 (103.67s)
--- PASS: TestAccAWSENI_ipv6_count (113.44s)
--- PASS: TestAccAWSENI_PrivateIpsCount (105.95s)
--- PASS: TestAccAWSENI_sourceDestCheck (102.45s)
--- PASS: TestAccAWSENI_tags (103.56s)
--- PASS: TestAccAWSENI_updatedDescription (86.64s)

--- PASS: TestAccDataSourceAwsNetworkInterface_basic (55.77s)
--- PASS: TestAccDataSourceAwsNetworkInterface_filters (60.57s)

@bflad bflad merged commit b1615b1 into hashicorp:master Nov 9, 2020
bflad added a commit that referenced this pull request Nov 9, 2020
@ghost
Copy link

ghost commented Nov 12, 2020

This has been released in version 3.15.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 Dec 10, 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 as resolved and limited conversation to collaborators Dec 10, 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/ec2 Issues and PRs that pertain to the ec2 service. size/XS Managed by automation to categorize the size of a PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants