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

r/aws_route: AWS Wavelength support #16961

Merged
merged 3 commits into from
Mar 26, 2021
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/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 @@ -140,6 +140,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 @@ -157,6 +158,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