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

[Bug]: panic: aws_vpc_peering_connection: invalid memory address or nil pointer dereference #27822

Closed
camlow325 opened this issue Nov 15, 2022 · 7 comments
Labels
bug Addresses a defect in current functionality. crash Results from or addresses a Terraform crash or kernel panic. service/vpc Issues and PRs that pertain to the vpc service.
Milestone

Comments

@camlow325
Copy link
Contributor

Terraform Core Version

1.0.8

AWS Provider Version

4.17.1

Affected Resource(s)

  • aws_vpc_peering_connection

Expected Behavior

Apply with resource successful.

Actual Behavior

Terraform crashed.

Relevant Error/Panic Output Snippet

No response

Terraform Configuration Files

resource "aws_vpc_peering_connection" "this" {
  auto_accept = true
  peer_vpc_id = ...
  vpc_id      = ...

  accepter {
    allow_remote_vpc_dns_resolution = false
  }

  requester {
    allow_remote_vpc_dns_resolution = false
  }

  tags = {}
}

Steps to Reproduce

terraform apply. Note that we have only seen this crash once so far, with the same code being applied each time.

Debug Output

No response

Panic Output

Stack trace from the terraform-provider-aws_v4.17.1_x5 plugin:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x5d553a0]

goroutine 1109 [running]:
	github.com/hashicorp/terraform-provider-aws/internal/service/ec2/vpc_peering_connection.go:376
github.com/hashicorp/terraform-provider-aws/internal/service/ec2.modifyVPCPeeringConnectionOptions.func1()
	github.com/hashicorp/terraform-provider-aws/internal/service/ec2/vpc_peering_connection.go:354 +0x125
github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource.RetryContext.func1()
	github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/resource/wait.go:27 +0x56
github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource.(*StateChangeConf).WaitForStateContext.func1()
	github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/resource/state.go:110 +0x21f
created by github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource.(*StateChangeConf).WaitForStateContext
	github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/resource/state.go:83 +0x1dd

Error: The terraform-provider-aws_v4.17.1_x5 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.

Important Factoids

No response

References

No response

Would you like to implement a fix?

No response

@camlow325 camlow325 added bug Addresses a defect in current functionality. needs-triage Waiting for first response or review from a maintainer. labels Nov 15, 2022
@github-actions
Copy link

Community Note

Voting for Prioritization

  • Please vote on this issue by adding a 👍 reaction to the original post to help the community and maintainers prioritize this request.
  • Please see our prioritization guide for information on how we prioritize.
  • 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.

Volunteering to Work on This Issue

  • If you are interested in working on this issue, please leave a comment.
  • If this would be your first contribution, please review the contribution guide.

@github-actions github-actions bot added crash Results from or addresses a Terraform crash or kernel panic. service/vpc Issues and PRs that pertain to the vpc service. labels Nov 15, 2022
@justinretzolk justinretzolk removed the needs-triage Waiting for first response or review from a maintainer. label Nov 15, 2022
@ewbankkit
Copy link
Contributor

ewbankkit commented Nov 16, 2022

func vpcPeeringConnectionOptionsEqual(o1 *ec2.VpcPeeringConnectionOptionsDescription, o2 *ec2.PeeringConnectionOptionsRequest) bool {
return aws.BoolValue(o1.AllowDnsResolutionFromRemoteVpc) == aws.BoolValue(o2.AllowDnsResolutionFromRemoteVpc) &&
aws.BoolValue(o1.AllowEgressFromLocalClassicLinkToRemoteVpc) == aws.BoolValue(o2.AllowEgressFromLocalClassicLinkToRemoteVpc) &&
aws.BoolValue(o1.AllowEgressFromLocalVpcToRemoteClassicLink) == aws.BoolValue(o2.AllowEgressFromLocalVpcToRemoteClassicLink)
}

called from

if v := vpcPeeringConnection.AccepterVpcInfo; v != nil && accepterPeeringConnectionOptions != nil {
if !vpcPeeringConnectionOptionsEqual(v.PeeringOptions, accepterPeeringConnectionOptions) {
return resource.RetryableError(errors.New("Accepter Options not stable"))
}
}

v.PeeringOptions is nil.

@matth-boise
Copy link

encountered a similar error from a newer version of the provider

Stack trace from the terraform-provider-aws_v4.51.0_x5 plugin:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x880c440]

goroutine 1466 [running]:
github.com/hashicorp/terraform-provider-aws/internal/service/ec2.vpcPeeringConnectionOptionsEqual(0xc0041d7e00?, 0xc002cc20d8?)
	github.com/hashicorp/terraform-provider-aws/internal/service/ec2/vpc_peering_connection.go:382
github.com/hashicorp/terraform-provider-aws/internal/service/ec2.modifyVPCPeeringConnectionOptions.func1()
	github.com/hashicorp/terraform-provider-aws/internal/service/ec2/vpc_peering_connection.go:360 +0x125
github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource.RetryContext.func1()
	github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/resource/wait.go:27 +0x56
github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource.(*StateChangeConf).WaitForStateContext.func1()
	github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/resource/state.go:110 +0x1ff
created by github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource.(*StateChangeConf).WaitForStateContext
	github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/resource/state.go:83 +0x1d8

ok to leave this as a comment in this issue? or better to create a new issue?

@ewbankkit
Copy link
Contributor

ewbankkit commented Apr 13, 2023

func vpcPeeringConnectionOptionsEqual(o1 *ec2.VpcPeeringConnectionOptionsDescription, o2 *ec2.PeeringConnectionOptionsRequest) bool {
return aws.BoolValue(o1.AllowDnsResolutionFromRemoteVpc) == aws.BoolValue(o2.AllowDnsResolutionFromRemoteVpc) &&
aws.BoolValue(o1.AllowEgressFromLocalClassicLinkToRemoteVpc) == aws.BoolValue(o2.AllowEgressFromLocalClassicLinkToRemoteVpc) &&
aws.BoolValue(o1.AllowEgressFromLocalVpcToRemoteClassicLink) == aws.BoolValue(o2.AllowEgressFromLocalVpcToRemoteClassicLink)
}

called from

if v := vpcPeeringConnection.AccepterVpcInfo; v != nil && accepterPeeringConnectionOptions != nil {
if !vpcPeeringConnectionOptionsEqual(v.PeeringOptions, accepterPeeringConnectionOptions) {
return resource.RetryableError(errors.New("Accepter Options not stable"))
}
}

v.PeeringOptions must be nil.

@jar-b
Copy link
Member

jar-b commented May 23, 2023

Closed by #30966, merged to main via #31392

@jar-b jar-b closed this as completed May 23, 2023
@jar-b jar-b added this to the v5.0.0 milestone May 23, 2023
@github-actions
Copy link

This functionality has been released in v5.0.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. Thank you!

@github-actions
Copy link

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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 25, 2023
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/vpc Issues and PRs that pertain to the vpc service.
Projects
None yet
Development

No branches or pull requests

5 participants