Skip to content

Commit

Permalink
Merge pull request #16961 from ewbankkit/f-aws_route-wavelength
Browse files Browse the repository at this point in the history
r/aws_route: AWS Wavelength support
  • Loading branch information
YakDriver authored Mar 26, 2021
2 parents a59bcfa + 0597561 commit 43f50a5
Show file tree
Hide file tree
Showing 5 changed files with 133 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .changelog/16961.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-notes:enhancement
resource/aws_route: Add `carrier_gateway_id` attribute
```
2 changes: 2 additions & 0 deletions aws/internal/service/ec2/finder/finder.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ type RouteFinder func(*ec2.EC2, string, string) (*ec2.Route, error)
// Returns NotFoundError if no route is found.
func RouteByIPv4Destination(conn *ec2.EC2, routeTableID, destinationCidr string) (*ec2.Route, error) {
routeTable, err := RouteTableByID(conn, routeTableID)

if err != nil {
return nil, err
}
Expand All @@ -239,6 +240,7 @@ func RouteByIPv4Destination(conn *ec2.EC2, routeTableID, destinationCidr string)
// Returns NotFoundError if no route is found.
func RouteByIPv6Destination(conn *ec2.EC2, routeTableID, destinationIpv6Cidr string) (*ec2.Route, error) {
routeTable, err := RouteTableByID(conn, routeTableID)

if err != nil {
return nil, err
}
Expand Down
13 changes: 13 additions & 0 deletions aws/resource_aws_route.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ var routeValidDestinations = []string{
}

var routeValidTargets = []string{
"carrier_gateway_id",
"egress_only_gateway_id",
"gateway_id",
"instance_id",
Expand Down Expand Up @@ -89,6 +90,13 @@ func resourceAwsRoute() *schema.Resource {
//
// Targets.
//
"carrier_gateway_id": {
Type: schema.TypeString,
Optional: true,
ExactlyOneOf: routeValidTargets,
ConflictsWith: []string{"destination_ipv6_cidr_block"}, // IPv4 destinations only.
},

"egress_only_gateway_id": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -203,6 +211,8 @@ func resourceAwsRouteCreate(d *schema.ResourceData, meta interface{}) error {
}

switch target := aws.String(target); targetAttributeKey {
case "carrier_gateway_id":
input.CarrierGatewayId = target
case "egress_only_gateway_id":
input.EgressOnlyInternetGatewayId = target
case "gateway_id":
Expand Down Expand Up @@ -317,6 +327,7 @@ func resourceAwsRouteRead(d *schema.ResourceData, meta interface{}) error {
return fmt.Errorf("error reading Route for Route Table (%s) with destination (%s): %w", routeTableID, destination, err)
}

d.Set("carrier_gateway_id", route.CarrierGatewayId)
d.Set("destination_cidr_block", route.DestinationCidrBlock)
d.Set("destination_ipv6_cidr_block", route.DestinationIpv6CidrBlock)
d.Set("destination_prefix_list_id", route.DestinationPrefixListId)
Expand Down Expand Up @@ -372,6 +383,8 @@ func resourceAwsRouteUpdate(d *schema.ResourceData, meta interface{}) error {
}

switch target := aws.String(target); targetAttributeKey {
case "carrier_gateway_id":
input.CarrierGatewayId = target
case "egress_only_gateway_id":
input.EgressOnlyInternetGatewayId = target
case "gateway_id":
Expand Down
Loading

0 comments on commit 43f50a5

Please sign in to comment.