Skip to content

Commit

Permalink
r/aws_route: Change 'finder.RouteTable' to 'finder.RouteTables' to su…
Browse files Browse the repository at this point in the history
…pport data source returning multiple route tables.

Acceptance test output:

$ make testacc TEST=./aws TESTARGS='-run=TestAccAWSRoute_basic\|TestAccAWSRoute_disappears' ACCTEST_PARALLELISM=2
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -count 1 -parallel 2 -run=TestAccAWSRoute_basic\|TestAccAWSRoute_disappears -timeout 120m
=== RUN   TestAccAWSRoute_basic
=== PAUSE TestAccAWSRoute_basic
=== RUN   TestAccAWSRoute_disappears
=== PAUSE TestAccAWSRoute_disappears
=== RUN   TestAccAWSRoute_disappears_RouteTable
=== PAUSE TestAccAWSRoute_disappears_RouteTable
=== CONT  TestAccAWSRoute_basic
=== CONT  TestAccAWSRoute_disappears_RouteTable
--- PASS: TestAccAWSRoute_disappears_RouteTable (33.82s)
=== CONT  TestAccAWSRoute_disappears
--- PASS: TestAccAWSRoute_basic (35.39s)
--- PASS: TestAccAWSRoute_disappears (31.99s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	65.901s
  • Loading branch information
ewbankkit committed Jan 23, 2021
1 parent 499b772 commit 5b93284
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions aws/internal/service/ec2/finder/finder.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,18 @@ func RouteTableByID(conn *ec2.EC2, routeTableID string) (*ec2.RouteTable, error)
RouteTableIds: aws.StringSlice([]string{routeTableID}),
}

return RouteTable(conn, input)
routeTables, err := RouteTables(conn, input)

if err != nil {
return nil, err
}

return routeTables[0], nil
}

func RouteTable(conn *ec2.EC2, input *ec2.DescribeRouteTablesInput) (*ec2.RouteTable, error) {
// RouteTables returns the route tables corresponding to the specified input.
// Returns NotFoundError if no route tables are found.
func RouteTables(conn *ec2.EC2, input *ec2.DescribeRouteTablesInput) ([]*ec2.RouteTable, error) {
output, err := conn.DescribeRouteTables(input)

if tfawserr.ErrCodeEquals(err, tfec2.ErrCodeInvalidRouteTableIDNotFound) {
Expand All @@ -109,7 +117,7 @@ func RouteTable(conn *ec2.EC2, input *ec2.DescribeRouteTablesInput) (*ec2.RouteT
}
}

return output.RouteTables[0], nil
return output.RouteTables, nil
}

// RouteFinder returns the route corresponding to the specified destination.
Expand Down

0 comments on commit 5b93284

Please sign in to comment.