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

r/aws_security_group_rule: Prevent crash when empty strings in prefix_list_ids #26220

Merged
merged 2 commits into from
Aug 10, 2022

Conversation

ewbankkit
Copy link
Contributor

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

Closes #26191.

Before fix:

% make testacc TESTARGS='-run=TestAccVPCSecurityGroupRule_prefixListEmptyString' PKG=ec2
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/ec2/... -v -count 1 -parallel 20  -run=TestAccVPCSecurityGroupRule_prefixListEmptyString -timeout 180m
=== RUN   TestAccVPCSecurityGroupRule_prefixListEmptyString
=== PAUSE TestAccVPCSecurityGroupRule_prefixListEmptyString
=== CONT  TestAccVPCSecurityGroupRule_prefixListEmptyString
panic: interface conversion: interface {} is nil, not string

goroutine 1917 [running]:
github.com/hashicorp/terraform-provider-aws/internal/service/ec2.expandIpPermission(0x0?, 0xc0064bbe30)
	/Users/ewbankkit/altsrc.2/github.com/terraform-providers/terraform-provider-aws/internal/service/ec2/vpc_security_group_rule.go:718 +0xf25
github.com/hashicorp/terraform-provider-aws/internal/service/ec2.resourceSecurityGroupRuleCreate(0x0?, {0x98c5bc0?, 0xc004ac0a80?})
	/Users/ewbankkit/altsrc.2/github.com/terraform-providers/terraform-provider-aws/internal/service/ec2/vpc_security_group_rule.go:155 +0x227
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).create(0xbce7060?, {0xbce7060?, 0xc0022d4090?}, 0xd?, {0x98c5bc0?, 0xc004ac0a80?})
	/Users/ewbankkit/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:695 +0x178
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0xc0032bfce0, {0xbce7060, 0xc0022d4090}, 0xc0015ef5f0, 0xc0055e8d00, {0x98c5bc0, 0xc004ac0a80})
	/Users/ewbankkit/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:837 +0xa7a
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0xc0030cab58, {0xbce7060?, 0xc0022d1fb0?}, 0xc0005c9310)
	/Users/ewbankkit/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/grpc_provider.go:1021 +0xe3c
github.com/hashicorp/terraform-plugin-mux/tf5muxserver.muxServer.ApplyResourceChange({0xc0027d4ea0, 0xc0027d4f00, {0xc0005c5900, 0x2, 0x2}, 0xc0027d4ed0, 0xc00309f3c0, 0xc005a8fc50, 0xc0027d4f30}, {0xbce7060, ...}, ...)
	/Users/ewbankkit/go/pkg/mod/github.com/hashicorp/[email protected]/tf5muxserver/mux_server_ApplyResourceChange.go:27 +0x142
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ApplyResourceChange(0xc002ed2460, {0xbce7060?, 0xc0022c59b0?}, 0xc000b19960)
	/Users/ewbankkit/go/pkg/mod/github.com/hashicorp/[email protected]/tfprotov5/tf5server/server.go:813 +0x4fc
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ApplyResourceChange_Handler({0xab5f2c0?, 0xc002ed2460}, {0xbce7060, 0xc0022c59b0}, 0xc000b19810, 0x0)
	/Users/ewbankkit/go/pkg/mod/github.com/hashicorp/[email protected]/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:385 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0xc0000005a0, {0xbcec808, 0xc00624a680}, 0xc0021818c0, 0xc00223ef60, 0x115062e0, 0x0)
	/Users/ewbankkit/go/pkg/mod/google.golang.org/[email protected]/server.go:1295 +0xb0b
google.golang.org/grpc.(*Server).handleStream(0xc0000005a0, {0xbcec808, 0xc00624a680}, 0xc0021818c0, 0x0)
	/Users/ewbankkit/go/pkg/mod/google.golang.org/[email protected]/server.go:1636 +0xa1b
google.golang.org/grpc.(*Server).serveStreams.func1.2()
	/Users/ewbankkit/go/pkg/mod/google.golang.org/[email protected]/server.go:932 +0x98
created by google.golang.org/grpc.(*Server).serveStreams.func1
	/Users/ewbankkit/go/pkg/mod/google.golang.org/[email protected]/server.go:930 +0x28a
FAIL	github.com/hashicorp/terraform-provider-aws/internal/service/ec2	13.934s
FAIL
make: *** [testacc] Error 1

Now:

% make testacc TESTARGS='-run=TestAccVPCSecurityGroupRule_prefixList' PKG=ec2 ACCTEST_PARALLELISM=2
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/ec2/... -v -count 1 -parallel 2  -run=TestAccVPCSecurityGroupRule_prefixList -timeout 180m
=== RUN   TestAccVPCSecurityGroupRule_prefixListEgress
=== PAUSE TestAccVPCSecurityGroupRule_prefixListEgress
=== RUN   TestAccVPCSecurityGroupRule_prefixListEmptyString
=== PAUSE TestAccVPCSecurityGroupRule_prefixListEmptyString
=== CONT  TestAccVPCSecurityGroupRule_prefixListEgress
=== CONT  TestAccVPCSecurityGroupRule_prefixListEmptyString
--- PASS: TestAccVPCSecurityGroupRule_prefixListEmptyString (1.76s)
--- PASS: TestAccVPCSecurityGroupRule_prefixListEgress (34.89s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/ec2	39.095s

@github-actions github-actions bot added service/vpc Issues and PRs that pertain to the vpc service. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. size/S Managed by automation to categorize the size of a PR. labels Aug 10, 2022
@ewbankkit ewbankkit added bug Addresses a defect in current functionality. crash Results from or addresses a Terraform crash or kernel panic. labels Aug 10, 2022
@github-actions github-actions bot added size/M Managed by automation to categorize the size of a PR. and removed size/S Managed by automation to categorize the size of a PR. labels Aug 10, 2022
@ewbankkit ewbankkit merged commit 26f63a0 into main Aug 10, 2022
@ewbankkit ewbankkit deleted the b-aws_security_group_rule.crash branch August 10, 2022 17:44
@github-actions github-actions bot added this to the v4.26.0 milestone Aug 10, 2022
github-actions bot pushed a commit that referenced this pull request Aug 10, 2022
@github-actions
Copy link

This functionality has been released in v4.26.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 pull request 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 related to this change, 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 Sep 12, 2022
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. size/M Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Provider plugin crashes with empty string for prefix_list_ids in aws_security_group_rule resource
1 participant