Skip to content

Commit

Permalink
r/aws_route: Correct capitalization of 'IPv4' and 'IPv6'.
Browse files Browse the repository at this point in the history
Acceptance test output:

$ make testacc TEST=./aws/ TESTARGS='-run=TestAccAWSRoute_' ACCTEST_PARALLELISM=2
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -count 1 -parallel 2 -run=TestAccAWSRoute_ -timeout 120m
=== RUN   TestAccAWSRoute_basic
=== PAUSE TestAccAWSRoute_basic
=== RUN   TestAccAWSRoute_disappears
=== PAUSE TestAccAWSRoute_disappears
=== RUN   TestAccAWSRoute_disappears_RouteTable
=== PAUSE TestAccAWSRoute_disappears_RouteTable
=== RUN   TestAccAWSRoute_IPv6_To_EgressOnlyInternetGateway
=== PAUSE TestAccAWSRoute_IPv6_To_EgressOnlyInternetGateway
=== RUN   TestAccAWSRoute_IPv6_To_InternetGateway
=== PAUSE TestAccAWSRoute_IPv6_To_InternetGateway
=== RUN   TestAccAWSRoute_IPv6_To_Instance
=== PAUSE TestAccAWSRoute_IPv6_To_Instance
=== RUN   TestAccAWSRoute_IPv6_To_NetworkInterface_Unattached
=== PAUSE TestAccAWSRoute_IPv6_To_NetworkInterface_Unattached
=== RUN   TestAccAWSRoute_IPv6_To_VpcPeeringConnection
=== PAUSE TestAccAWSRoute_IPv6_To_VpcPeeringConnection
=== RUN   TestAccAWSRoute_IPv6_To_VpnGateway
=== PAUSE TestAccAWSRoute_IPv6_To_VpnGateway
=== RUN   TestAccAWSRoute_IPv4_To_VpnGateway
=== PAUSE TestAccAWSRoute_IPv4_To_VpnGateway
=== RUN   TestAccAWSRoute_IPv4_To_Instance
=== PAUSE TestAccAWSRoute_IPv4_To_Instance
=== RUN   TestAccAWSRoute_IPv4_To_NetworkInterface_Unattached
=== PAUSE TestAccAWSRoute_IPv4_To_NetworkInterface_Unattached
=== RUN   TestAccAWSRoute_IPv4_To_NetworkInterface_Attached
=== PAUSE TestAccAWSRoute_IPv4_To_NetworkInterface_Attached
=== RUN   TestAccAWSRoute_IPv4_To_NetworkInterface_TwoAttachments
=== PAUSE TestAccAWSRoute_IPv4_To_NetworkInterface_TwoAttachments
=== RUN   TestAccAWSRoute_IPv4_To_VpcPeeringConnection
=== PAUSE TestAccAWSRoute_IPv4_To_VpcPeeringConnection
=== RUN   TestAccAWSRoute_IPv4_To_NatGateway
=== PAUSE TestAccAWSRoute_IPv4_To_NatGateway
=== RUN   TestAccAWSRoute_DoesNotCrashWithVpcEndpoint
=== PAUSE TestAccAWSRoute_DoesNotCrashWithVpcEndpoint
=== RUN   TestAccAWSRoute_IPv4_To_TransitGateway
=== PAUSE TestAccAWSRoute_IPv4_To_TransitGateway
=== RUN   TestAccAWSRoute_IPv6_To_TransitGateway
=== PAUSE TestAccAWSRoute_IPv6_To_TransitGateway
=== RUN   TestAccAWSRoute_IPv4_To_LocalGateway
=== PAUSE TestAccAWSRoute_IPv4_To_LocalGateway
=== RUN   TestAccAWSRoute_IPv6_To_LocalGateway
=== PAUSE TestAccAWSRoute_IPv6_To_LocalGateway
=== RUN   TestAccAWSRoute_ConditionalCidrBlock
=== PAUSE TestAccAWSRoute_ConditionalCidrBlock
=== RUN   TestAccAWSRoute_IPv4_Update_Target
=== PAUSE TestAccAWSRoute_IPv4_Update_Target
=== RUN   TestAccAWSRoute_IPv6_Update_Target
=== PAUSE TestAccAWSRoute_IPv6_Update_Target
=== RUN   TestAccAWSRoute_IPv4_To_VpcEndpoint
=== PAUSE TestAccAWSRoute_IPv4_To_VpcEndpoint
=== RUN   TestAccAWSRoute_LocalRoute
=== PAUSE TestAccAWSRoute_LocalRoute
=== CONT  TestAccAWSRoute_basic
=== CONT  TestAccAWSRoute_IPv4_To_VpcPeeringConnection
--- PASS: TestAccAWSRoute_IPv4_To_VpcPeeringConnection (27.43s)
=== CONT  TestAccAWSRoute_LocalRoute
--- PASS: TestAccAWSRoute_basic (36.72s)
=== CONT  TestAccAWSRoute_IPv4_To_VpcEndpoint
--- PASS: TestAccAWSRoute_LocalRoute (21.98s)
=== CONT  TestAccAWSRoute_IPv6_Update_Target
--- PASS: TestAccAWSRoute_IPv6_Update_Target (226.03s)
=== CONT  TestAccAWSRoute_IPv4_Update_Target
--- PASS: TestAccAWSRoute_IPv4_To_VpcEndpoint (273.71s)
=== CONT  TestAccAWSRoute_ConditionalCidrBlock
=== CONT  TestAccAWSRoute_IPv6_To_LocalGateway
--- PASS: TestAccAWSRoute_ConditionalCidrBlock (51.91s)
=== CONT  TestAccAWSRoute_IPv6_To_LocalGateway
    data_source_aws_outposts_outposts_test.go:66: skipping since no Outposts found
--- SKIP: TestAccAWSRoute_IPv6_To_LocalGateway (1.28s)
=== CONT  TestAccAWSRoute_IPv4_To_LocalGateway
    data_source_aws_outposts_outposts_test.go:66: skipping since no Outposts found
--- SKIP: TestAccAWSRoute_IPv4_To_LocalGateway (1.10s)
=== CONT  TestAccAWSRoute_IPv6_To_TransitGateway
--- PASS: TestAccAWSRoute_IPv6_To_TransitGateway (357.84s)
=== CONT  TestAccAWSRoute_IPv4_To_TransitGateway
--- PASS: TestAccAWSRoute_IPv4_Update_Target (626.78s)
=== CONT  TestAccAWSRoute_DoesNotCrashWithVpcEndpoint
--- PASS: TestAccAWSRoute_DoesNotCrashWithVpcEndpoint (43.28s)
=== CONT  TestAccAWSRoute_IPv4_To_NatGateway
--- PASS: TestAccAWSRoute_IPv4_To_TransitGateway (399.08s)
=== CONT  TestAccAWSRoute_IPv6_To_VpcPeeringConnection
--- PASS: TestAccAWSRoute_IPv6_To_VpcPeeringConnection (25.57s)
=== CONT  TestAccAWSRoute_IPv4_To_NetworkInterface_TwoAttachments
--- PASS: TestAccAWSRoute_IPv4_To_NatGateway (228.62s)
=== CONT  TestAccAWSRoute_IPv4_To_NetworkInterface_Attached
--- PASS: TestAccAWSRoute_IPv4_To_NetworkInterface_TwoAttachments (190.46s)
=== CONT  TestAccAWSRoute_IPv4_To_NetworkInterface_Unattached
--- PASS: TestAccAWSRoute_IPv4_To_NetworkInterface_Unattached (57.67s)
=== CONT  TestAccAWSRoute_IPv4_To_Instance
--- PASS: TestAccAWSRoute_IPv4_To_NetworkInterface_Attached (340.04s)
=== CONT  TestAccAWSRoute_IPv4_To_VpnGateway
--- PASS: TestAccAWSRoute_IPv4_To_VpnGateway (35.60s)
=== CONT  TestAccAWSRoute_IPv6_To_VpnGateway
--- PASS: TestAccAWSRoute_IPv6_To_VpnGateway (41.86s)
=== CONT  TestAccAWSRoute_IPv6_To_InternetGateway
--- PASS: TestAccAWSRoute_IPv6_To_InternetGateway (34.47s)
=== CONT  TestAccAWSRoute_IPv6_To_NetworkInterface_Unattached
--- PASS: TestAccAWSRoute_IPv6_To_NetworkInterface_Unattached (58.80s)
=== CONT  TestAccAWSRoute_IPv6_To_Instance
--- PASS: TestAccAWSRoute_IPv4_To_Instance (326.97s)
=== CONT  TestAccAWSRoute_disappears_RouteTable
--- PASS: TestAccAWSRoute_disappears_RouteTable (33.05s)
=== CONT  TestAccAWSRoute_IPv6_To_EgressOnlyInternetGateway
--- PASS: TestAccAWSRoute_IPv6_To_EgressOnlyInternetGateway (37.46s)
=== CONT  TestAccAWSRoute_disappears
--- PASS: TestAccAWSRoute_disappears (31.77s)
--- PASS: TestAccAWSRoute_IPv6_To_Instance (327.89s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	2012.898s
  • Loading branch information
ewbankkit committed Jan 5, 2021
1 parent 31ff980 commit daedff7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
12 changes: 7 additions & 5 deletions aws/internal/service/ec2/finder/finder.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,18 +87,20 @@ func RouteTableByID(conn *ec2.EC2, routeTableID string) (*ec2.RouteTable, error)
return nil, err
}

if output == nil || len(output.RouteTables) == 0 || output.RouteTables[0] == nil {
if output == nil || len(output.RouteTables) == 0 {
return nil, nil
}

return output.RouteTables[0], nil
}

// RouteFinder returns the route corresponding to the specified destination.
// Returns nil if no route is found.
type RouteFinder func(*ec2.EC2, string, string) (*ec2.Route, error)

// RouteByIpv4Destination returns the route corresponding to the specified IPv4 destination.
// RouteByIPv4Destination returns the route corresponding to the specified IPv4 destination.
// Returns nil if no route is found.
func RouteByIpv4Destination(conn *ec2.EC2, routeTableID, destinationCidr string) (*ec2.Route, error) {
func RouteByIPv4Destination(conn *ec2.EC2, routeTableID, destinationCidr string) (*ec2.Route, error) {
routeTable, err := RouteTableByID(conn, routeTableID)
if err != nil {
return nil, err
Expand All @@ -113,9 +115,9 @@ func RouteByIpv4Destination(conn *ec2.EC2, routeTableID, destinationCidr string)
return nil, nil
}

// RouteByIpv6Destination returns the route corresponding to the specified IPv6 destination.
// RouteByIPv6Destination returns the route corresponding to the specified IPv6 destination.
// Returns nil if no route is found.
func RouteByIpv6Destination(conn *ec2.EC2, routeTableID, destinationIpv6Cidr string) (*ec2.Route, error) {
func RouteByIPv6Destination(conn *ec2.EC2, routeTableID, destinationIpv6Cidr string) (*ec2.Route, error) {
routeTable, err := RouteTableByID(conn, routeTableID)
if err != nil {
return nil, err
Expand Down
8 changes: 4 additions & 4 deletions aws/resource_aws_route.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,10 @@ func resourceAwsRouteCreate(d *schema.ResourceData, meta interface{}) error {
switch destination := aws.String(destination); destinationAttributeKey {
case "destination_cidr_block":
input.DestinationCidrBlock = destination
routeFinder = finder.RouteByIpv4Destination
routeFinder = finder.RouteByIPv4Destination
case "destination_ipv6_cidr_block":
input.DestinationIpv6CidrBlock = destination
routeFinder = finder.RouteByIpv6Destination
routeFinder = finder.RouteByIPv6Destination
default:
return fmt.Errorf("error creating Route: unexpected route destination attribute: %q", destinationAttributeKey)
}
Expand Down Expand Up @@ -298,9 +298,9 @@ func resourceAwsRouteRead(d *schema.ResourceData, meta interface{}) error {

switch destinationAttributeKey {
case "destination_cidr_block":
routeFinder = finder.RouteByIpv4Destination
routeFinder = finder.RouteByIPv4Destination
case "destination_ipv6_cidr_block":
routeFinder = finder.RouteByIpv6Destination
routeFinder = finder.RouteByIPv6Destination
default:
return fmt.Errorf("error reading Route: unexpected route destination attribute: %q", destinationAttributeKey)
}
Expand Down
4 changes: 2 additions & 2 deletions aws/resource_aws_route_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1322,9 +1322,9 @@ func testAccCheckAWSRouteDestroy(s *terraform.State) error {
var route *ec2.Route
var err error
if v := rs.Primary.Attributes["destination_cidr_block"]; v != "" {
route, err = finder.RouteByIpv4Destination(conn, rs.Primary.Attributes["route_table_id"], v)
route, err = finder.RouteByIPv4Destination(conn, rs.Primary.Attributes["route_table_id"], v)
} else if v := rs.Primary.Attributes["destination_ipv6_cidr_block"]; v != "" {
route, err = finder.RouteByIpv6Destination(conn, rs.Primary.Attributes["route_table_id"], v)
route, err = finder.RouteByIPv6Destination(conn, rs.Primary.Attributes["route_table_id"], v)
}

if route == nil && err == nil {
Expand Down

0 comments on commit daedff7

Please sign in to comment.