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

d/aws_ami: Fix interface conversion: interface {} is types.ProductCodeValues, not string panic #37977

Merged
merged 3 commits into from
Jun 14, 2024

Conversation

ewbankkit
Copy link
Contributor

@ewbankkit ewbankkit commented Jun 14, 2024

Description

Removes the custom set hash functions from the aws_ami data source -- these are not required for Computed attributes.

Relations

Closes #37973.

Output from Acceptance Testing

Before fix

% make testacc TESTARGS='-run=TestAccEC2AMIDataSource_productCode' PKG=ec2
make: Verifying source code with gofmt...
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go1.22.2 test ./internal/service/ec2/... -v -count 1 -parallel 20  -run=TestAccEC2AMIDataSource_productCode -timeout 360m
=== RUN   TestAccEC2AMIDataSource_productCode
=== PAUSE TestAccEC2AMIDataSource_productCode
=== CONT  TestAccEC2AMIDataSource_productCode
panic: interface conversion: interface {} is types.ProductCodeValues, not string

goroutine 108 [running]:
github.com/hashicorp/terraform-provider-aws/internal/service/ec2.amiProductCodesHash({0x1170c5600?, 0x14008f80210})
	/Users/kewbank/altsrc.1/github.com/hashicorp/terraform-provider-aws/internal/service/ec2/ec2_ami_data_source.go:456 +0x194
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Set).hash(0x0?, {0x1170c5600?, 0x14008f80210?})
	/Users/kewbank/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/v2@v2.34.0/helper/schema/set.go:221 +0x34
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Set).add(0x14008de56c0, {0x1170c5600, 0x14008f80210}, 0x0)
	/Users/kewbank/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/v2@v2.34.0/helper/schema/set.go:201 +0x70
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Set).Add(...)
	/Users/kewbank/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/v2@v2.34.0/helper/schema/set.go:79
github.com/hashicorp/terraform-provider-aws/internal/service/ec2.flattenAMIProductCodes({0x14008de4dc0, 0x1, 0x10?})
	/Users/kewbank/altsrc.1/github.com/hashicorp/terraform-provider-aws/internal/service/ec2/ec2_ami_data_source.go:391 +0x74
github.com/hashicorp/terraform-provider-aws/internal/service/ec2.dataSourceAMIRead({0x11912d830, 0x14008e60030}, 0x14008c7ef00, {0x118eaa000?, 0x14004caa410})
	/Users/kewbank/altsrc.1/github.com/hashicorp/terraform-provider-aws/internal/service/ec2/ec2_ami_data_source.go:330 +0x978
github.com/hashicorp/terraform-provider-aws/internal/provider.New.(*wrappedDataSource).Read.interceptedHandler[...].func7(0x14008c7ef00?, {0x118eaa000?, 0x14004caa410})
	/Users/kewbank/altsrc.1/github.com/hashicorp/terraform-provider-aws/internal/provider/intercept.go:113 +0x1d8
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).read(0x11912d830?, {0x11912d830?, 0x14008cedcb0?}, 0xd?, {0x118eaa000?, 0x14004caa410?})
	/Users/kewbank/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/v2@v2.34.0/helper/schema/resource.go:818 +0x64
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).ReadDataApply(0x14005a28b60, {0x11912d830, 0x14008cedcb0}, 0x14008c7ee00, {0x118eaa000, 0x14004caa410})
	/Users/kewbank/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/v2@v2.34.0/helper/schema/resource.go:1043 +0x110
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ReadDataSource(0x14003f762e8, {0x11912d830?, 0x14008cedc20?}, 0x14008ced950)
	/Users/kewbank/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/v2@v2.34.0/helper/schema/grpc_provider.go:1434 +0x5a4
github.com/hashicorp/terraform-plugin-mux/tf5muxserver.(*muxServer).ReadDataSource(0x140008220e0, {0x11912d830?, 0x14008ced980?}, 0x14008ced950)
	/Users/kewbank/go/pkg/mod/github.com/hashicorp/terraform-plugin-mux@v0.16.0/tf5muxserver/mux_server_ReadDataSource.go:36 +0x184
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ReadDataSource(0x140005f2500, {0x11912d830?, 0x14008cecfc0?}, 0x14004108910)
	/Users/kewbank/go/pkg/mod/github.com/hashicorp/terraform-plugin-go@v0.23.0/tfprotov5/tf5server/server.go:688 +0x1d8
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ReadDataSource_Handler({0x118c8e480, 0x140005f2500}, {0x11912d830, 0x14008cecfc0}, 0x14008c7e880, 0x0)
	/Users/kewbank/go/pkg/mod/github.com/hashicorp/terraform-plugin-go@v0.23.0/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:572 +0x1c0
google.golang.org/grpc.(*Server).processUnaryRPC(0x14000fb6000, {0x11912d830, 0x14008cecf30}, {0x11917c780, 0x14006332300}, 0x1400404fe60, 0x140049627b0, 0x1229c9d20, 0x0)
	/Users/kewbank/go/pkg/mod/google.golang.org/grpc@v1.63.2/server.go:1369 +0xb58
google.golang.org/grpc.(*Server).handleStream(0x14000fb6000, {0x11917c780, 0x14006332300}, 0x1400404fe60)
	/Users/kewbank/go/pkg/mod/google.golang.org/grpc@v1.63.2/server.go:1780 +0xb20
google.golang.org/grpc.(*Server).serveStreams.func2.1()
	/Users/kewbank/go/pkg/mod/google.golang.org/grpc@v1.63.2/server.go:1019 +0x8c
created by google.golang.org/grpc.(*Server).serveStreams.func2 in goroutine 643
	/Users/kewbank/go/pkg/mod/google.golang.org/grpc@v1.63.2/server.go:1030 +0x13c
FAIL	github.com/hashicorp/terraform-provider-aws/internal/service/ec2	13.051s
FAIL
make: *** [testacc] Error 1

After fix

% make testacc TESTARGS='-run=TestAccEC2AMIDataSource_' PKG=ec2         
make: Verifying source code with gofmt...
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go1.22.2 test ./internal/service/ec2/... -v -count 1 -parallel 20  -run=TestAccEC2AMIDataSource_ -timeout 360m
=== RUN   TestAccEC2AMIDataSource_linuxInstance
=== PAUSE TestAccEC2AMIDataSource_linuxInstance
=== RUN   TestAccEC2AMIDataSource_windowsInstance
=== PAUSE TestAccEC2AMIDataSource_windowsInstance
=== RUN   TestAccEC2AMIDataSource_instanceStore
=== PAUSE TestAccEC2AMIDataSource_instanceStore
=== RUN   TestAccEC2AMIDataSource_localNameFilter
=== PAUSE TestAccEC2AMIDataSource_localNameFilter
=== RUN   TestAccEC2AMIDataSource_gp3BlockDevice
=== PAUSE TestAccEC2AMIDataSource_gp3BlockDevice
=== RUN   TestAccEC2AMIDataSource_productCode
=== PAUSE TestAccEC2AMIDataSource_productCode
=== CONT  TestAccEC2AMIDataSource_linuxInstance
=== CONT  TestAccEC2AMIDataSource_localNameFilter
=== CONT  TestAccEC2AMIDataSource_productCode
=== CONT  TestAccEC2AMIDataSource_gp3BlockDevice
=== CONT  TestAccEC2AMIDataSource_instanceStore
=== CONT  TestAccEC2AMIDataSource_windowsInstance
--- PASS: TestAccEC2AMIDataSource_productCode (23.70s)
--- PASS: TestAccEC2AMIDataSource_linuxInstance (26.80s)
--- PASS: TestAccEC2AMIDataSource_localNameFilter (31.10s)
--- PASS: TestAccEC2AMIDataSource_instanceStore (31.12s)
--- PASS: TestAccEC2AMIDataSource_windowsInstance (31.26s)
--- PASS: TestAccEC2AMIDataSource_gp3BlockDevice (56.68s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/ec2	61.246s

@ewbankkit ewbankkit requested a review from a team as a code owner June 14, 2024 14:03
Copy link

Community Note

Voting for Prioritization

  • Please vote on this pull request by adding a 👍 reaction to the original post to help the community and maintainers prioritize this pull 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.

For Submitters

  • Review the contribution guide relating to the type of change you are making to ensure all of the necessary steps have been taken.
  • For new resources and data sources, use skaff to generate scaffolding with comments detailing common expectations.
  • Whether or not the branch has been rebased will not impact prioritization, but doing so is always a welcome surprise.

@github-actions github-actions bot added size/M Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. service/ec2 Issues and PRs that pertain to the ec2 service. labels Jun 14, 2024
@terraform-aws-provider terraform-aws-provider bot added the prioritized Part of the maintainer teams immediate focus. To be addressed within the current quarter. label Jun 14, 2024
@ewbankkit ewbankkit added bug Addresses a defect in current functionality. crash Results from or addresses a Terraform crash or kernel panic. labels Jun 14, 2024
Copy link
Contributor

@johnsonaj johnsonaj left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

% make testacc TESTARGS='-run=TestAccEC2AMIDataSource_' PKG=ec2

make: Verifying source code with gofmt...
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go1.22.2 test ./internal/service/ec2/... -v -count 1 -parallel 20  -run=TestAccEC2AMIDataSource_ -timeout 360m
=== RUN   TestAccEC2AMIDataSource_linuxInstance
=== PAUSE TestAccEC2AMIDataSource_linuxInstance
=== RUN   TestAccEC2AMIDataSource_windowsInstance
=== PAUSE TestAccEC2AMIDataSource_windowsInstance
=== RUN   TestAccEC2AMIDataSource_instanceStore
=== PAUSE TestAccEC2AMIDataSource_instanceStore
=== RUN   TestAccEC2AMIDataSource_localNameFilter
=== PAUSE TestAccEC2AMIDataSource_localNameFilter
=== RUN   TestAccEC2AMIDataSource_gp3BlockDevice
=== PAUSE TestAccEC2AMIDataSource_gp3BlockDevice
=== RUN   TestAccEC2AMIDataSource_productCode
=== PAUSE TestAccEC2AMIDataSource_productCode
=== CONT  TestAccEC2AMIDataSource_linuxInstance
=== CONT  TestAccEC2AMIDataSource_localNameFilter
=== CONT  TestAccEC2AMIDataSource_gp3BlockDevice
=== CONT  TestAccEC2AMIDataSource_productCode
=== CONT  TestAccEC2AMIDataSource_instanceStore
=== CONT  TestAccEC2AMIDataSource_windowsInstance
--- PASS: TestAccEC2AMIDataSource_linuxInstance (10.71s)
--- PASS: TestAccEC2AMIDataSource_localNameFilter (10.78s)
--- PASS: TestAccEC2AMIDataSource_instanceStore (10.79s)
--- PASS: TestAccEC2AMIDataSource_productCode (10.89s)
--- PASS: TestAccEC2AMIDataSource_windowsInstance (11.55s)
--- PASS: TestAccEC2AMIDataSource_gp3BlockDevice (59.09s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/ec2	65.051s

@ewbankkit ewbankkit merged commit cba256a into main Jun 14, 2024
108 checks passed
@ewbankkit ewbankkit deleted the b-d/aws_ami.amiProductCodesHash-crash branch June 14, 2024 14:45
@github-actions github-actions bot added this to the v5.55.0 milestone Jun 14, 2024
terraform-aws-provider bot pushed a commit that referenced this pull request Jun 14, 2024
Copy link

This functionality has been released in v5.54.1 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 github-actions bot removed the prioritized Part of the maintainer teams immediate focus. To be addressed within the current quarter. label Jun 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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/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.

[Bug]: 5.54 release - panic crash when using the aws_ami data source
2 participants