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

service/transitgateway: Fix resource Read pagination regression causing NotFound errors #38011

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/38011.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
service/transitgateway: Fix resource Read pagination regression causing `NotFound` errors
```
7 changes: 7 additions & 0 deletions .ci/semgrep/migrate/paginator.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
rules:
- id: paginator-more-pages
languages: [go]
message: Use `for pages.HasMorePages()`, not `if pages.HasMorePages()`
patterns:
- pattern-regex: 'if\s+pages\.HasMorePages\(\)'
severity: ERROR
30 changes: 15 additions & 15 deletions internal/service/ec2/findv2.go
Original file line number Diff line number Diff line change
Expand Up @@ -3209,7 +3209,7 @@ func findTransitGateways(ctx context.Context, conn *ec2.Client, input *ec2.Descr
var output []awstypes.TransitGateway

pages := ec2.NewDescribeTransitGatewaysPaginator(conn, input)
if pages.HasMorePages() {
for pages.HasMorePages() {
page, err := pages.NextPage(ctx)

if tfawserr.ErrCodeEquals(err, errCodeInvalidTransitGatewayIDNotFound) {
Expand Down Expand Up @@ -3271,7 +3271,7 @@ func findTransitGatewayAttachments(ctx context.Context, conn *ec2.Client, input
var output []awstypes.TransitGatewayAttachment

pages := ec2.NewDescribeTransitGatewayAttachmentsPaginator(conn, input)
if pages.HasMorePages() {
for pages.HasMorePages() {
page, err := pages.NextPage(ctx)

if tfawserr.ErrCodeEquals(err, errCodeInvalidTransitGatewayAttachmentIDNotFound) {
Expand Down Expand Up @@ -3326,7 +3326,7 @@ func findTransitGatewayConnects(ctx context.Context, conn *ec2.Client, input *ec
var output []awstypes.TransitGatewayConnect

pages := ec2.NewDescribeTransitGatewayConnectsPaginator(conn, input)
if pages.HasMorePages() {
for pages.HasMorePages() {
page, err := pages.NextPage(ctx)

if tfawserr.ErrCodeEquals(err, errCodeInvalidTransitGatewayAttachmentIDNotFound) {
Expand Down Expand Up @@ -3393,7 +3393,7 @@ func findTransitGatewayConnectPeers(ctx context.Context, conn *ec2.Client, input
var output []awstypes.TransitGatewayConnectPeer

pages := ec2.NewDescribeTransitGatewayConnectPeersPaginator(conn, input)
if pages.HasMorePages() {
for pages.HasMorePages() {
page, err := pages.NextPage(ctx)

if tfawserr.ErrCodeEquals(err, errCodeInvalidTransitGatewayConnectPeerIDNotFound) {
Expand Down Expand Up @@ -3455,7 +3455,7 @@ func findTransitGatewayMulticastDomains(ctx context.Context, conn *ec2.Client, i
var output []awstypes.TransitGatewayMulticastDomain

pages := ec2.NewDescribeTransitGatewayMulticastDomainsPaginator(conn, input)
if pages.HasMorePages() {
for pages.HasMorePages() {
page, err := pages.NextPage(ctx)

if tfawserr.ErrCodeEquals(err, errCodeInvalidTransitGatewayMulticastDomainIdNotFound) {
Expand Down Expand Up @@ -3517,7 +3517,7 @@ func findTransitGatewayMulticastDomainAssociations(ctx context.Context, conn *ec
var output []awstypes.TransitGatewayMulticastDomainAssociation

pages := ec2.NewGetTransitGatewayMulticastDomainAssociationsPaginator(conn, input)
if pages.HasMorePages() {
for pages.HasMorePages() {
page, err := pages.NextPage(ctx)

if tfawserr.ErrCodeEquals(err, errCodeInvalidTransitGatewayMulticastDomainIdNotFound) {
Expand Down Expand Up @@ -3573,7 +3573,7 @@ func findTransitGatewayMulticastGroups(ctx context.Context, conn *ec2.Client, in
var output []awstypes.TransitGatewayMulticastGroup

pages := ec2.NewSearchTransitGatewayMulticastGroupsPaginator(conn, input)
if pages.HasMorePages() {
for pages.HasMorePages() {
page, err := pages.NextPage(ctx)

if tfawserr.ErrCodeEquals(err, errCodeInvalidTransitGatewayMulticastDomainIdNotFound) {
Expand Down Expand Up @@ -3682,7 +3682,7 @@ func findTransitGatewayPeeringAttachments(ctx context.Context, conn *ec2.Client,
var output []awstypes.TransitGatewayPeeringAttachment

pages := ec2.NewDescribeTransitGatewayPeeringAttachmentsPaginator(conn, input)
if pages.HasMorePages() {
for pages.HasMorePages() {
page, err := pages.NextPage(ctx)

if tfawserr.ErrCodeEquals(err, errCodeInvalidTransitGatewayAttachmentIDNotFound) {
Expand Down Expand Up @@ -3748,7 +3748,7 @@ func findTransitGatewayPrefixListReferences(ctx context.Context, conn *ec2.Clien
var output []awstypes.TransitGatewayPrefixListReference

pages := ec2.NewGetTransitGatewayPrefixListReferencesPaginator(conn, input)
if pages.HasMorePages() {
for pages.HasMorePages() {
page, err := pages.NextPage(ctx)

if tfawserr.ErrCodeEquals(err, errCodeInvalidRouteTableIDNotFound) {
Expand Down Expand Up @@ -3870,7 +3870,7 @@ func findTransitGatewayPolicyTables(ctx context.Context, conn *ec2.Client, input
var output []awstypes.TransitGatewayPolicyTable

pages := ec2.NewDescribeTransitGatewayPolicyTablesPaginator(conn, input)
if pages.HasMorePages() {
for pages.HasMorePages() {
page, err := pages.NextPage(ctx)

if tfawserr.ErrCodeEquals(err, errCodeInvalidTransitGatewayPolicyTableIdNotFound) {
Expand All @@ -3894,7 +3894,7 @@ func findTransitGatewayRouteTables(ctx context.Context, conn *ec2.Client, input
var output []awstypes.TransitGatewayRouteTable

pages := ec2.NewDescribeTransitGatewayRouteTablesPaginator(conn, input)
if pages.HasMorePages() {
for pages.HasMorePages() {
page, err := pages.NextPage(ctx)

if tfawserr.ErrCodeEquals(err, errCodeInvalidRouteTableIDNotFound) {
Expand Down Expand Up @@ -4039,7 +4039,7 @@ func findTransitGatewayPolicyTableAssociations(ctx context.Context, conn *ec2.Cl
var output []awstypes.TransitGatewayPolicyTableAssociation

pages := ec2.NewGetTransitGatewayPolicyTableAssociationsPaginator(conn, input)
if pages.HasMorePages() {
for pages.HasMorePages() {
page, err := pages.NextPage(ctx)

if tfawserr.ErrCodeEquals(err, errCodeInvalidTransitGatewayPolicyTableIdNotFound) {
Expand Down Expand Up @@ -4073,7 +4073,7 @@ func findTransitGatewayRouteTableAssociations(ctx context.Context, conn *ec2.Cli
var output []awstypes.TransitGatewayRouteTableAssociation

pages := ec2.NewGetTransitGatewayRouteTableAssociationsPaginator(conn, input)
if pages.HasMorePages() {
for pages.HasMorePages() {
page, err := pages.NextPage(ctx)

if tfawserr.ErrCodeEquals(err, errCodeInvalidRouteTableIDNotFound) {
Expand Down Expand Up @@ -4138,7 +4138,7 @@ func findTransitGatewayRouteTablePropagations(ctx context.Context, conn *ec2.Cli
var output []awstypes.TransitGatewayRouteTablePropagation

pages := ec2.NewGetTransitGatewayRouteTablePropagationsPaginator(conn, input)
if pages.HasMorePages() {
for pages.HasMorePages() {
page, err := pages.NextPage(ctx)

if tfawserr.ErrCodeEquals(err, errCodeInvalidRouteTableIDNotFound) {
Expand Down Expand Up @@ -4172,7 +4172,7 @@ func findTransitGatewayVPCAttachments(ctx context.Context, conn *ec2.Client, inp
var output []awstypes.TransitGatewayVpcAttachment

pages := ec2.NewDescribeTransitGatewayVpcAttachmentsPaginator(conn, input)
if pages.HasMorePages() {
for pages.HasMorePages() {
page, err := pages.NextPage(ctx)

if tfawserr.ErrCodeEquals(err, errCodeInvalidTransitGatewayAttachmentIDNotFound) {
Expand Down
Loading