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

[WIP] Update 'aws_route' to handle changes in IPv6 route entries #12062

Closed
wants to merge 1 commit into from
Closed
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
56 changes: 43 additions & 13 deletions aws/resource_aws_route.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,9 +385,15 @@ func resourceAwsRouteUpdate(d *schema.ResourceData, meta interface{}) error {
switch setTarget {
case "gateway_id":
replaceOpts = &ec2.ReplaceRouteInput{
RouteTableId: aws.String(d.Get("route_table_id").(string)),
DestinationCidrBlock: aws.String(d.Get("destination_cidr_block").(string)),
GatewayId: aws.String(d.Get("gateway_id").(string)),
RouteTableId: aws.String(d.Get("route_table_id").(string)),
GatewayId: aws.String(d.Get("gateway_id").(string)),
}
if v, ok := d.GetOk("destination_cidr_block"); ok {
replaceOpts.DestinationCidrBlock = aws.String(v.(string))
}

if v, ok := d.GetOk("destination_ipv6_cidr_block"); ok {
replaceOpts.DestinationIpv6CidrBlock = aws.String(v.(string))
}
case "egress_only_gateway_id":
replaceOpts = &ec2.ReplaceRouteInput{
Expand All @@ -403,28 +409,52 @@ func resourceAwsRouteUpdate(d *schema.ResourceData, meta interface{}) error {
}
case "instance_id":
replaceOpts = &ec2.ReplaceRouteInput{
RouteTableId: aws.String(d.Get("route_table_id").(string)),
DestinationCidrBlock: aws.String(d.Get("destination_cidr_block").(string)),
InstanceId: aws.String(d.Get("instance_id").(string)),
RouteTableId: aws.String(d.Get("route_table_id").(string)),
InstanceId: aws.String(d.Get("instance_id").(string)),
}
if v, ok := d.GetOk("destination_cidr_block"); ok {
replaceOpts.DestinationCidrBlock = aws.String(v.(string))
}

if v, ok := d.GetOk("destination_ipv6_cidr_block"); ok {
replaceOpts.DestinationIpv6CidrBlock = aws.String(v.(string))
}
case "network_interface_id":
replaceOpts = &ec2.ReplaceRouteInput{
RouteTableId: aws.String(d.Get("route_table_id").(string)),
DestinationCidrBlock: aws.String(d.Get("destination_cidr_block").(string)),
NetworkInterfaceId: aws.String(d.Get("network_interface_id").(string)),
RouteTableId: aws.String(d.Get("route_table_id").(string)),
NetworkInterfaceId: aws.String(d.Get("network_interface_id").(string)),
}
if v, ok := d.GetOk("destination_cidr_block"); ok {
replaceOpts.DestinationCidrBlock = aws.String(v.(string))
}

if v, ok := d.GetOk("destination_ipv6_cidr_block"); ok {
replaceOpts.DestinationIpv6CidrBlock = aws.String(v.(string))
}
case "transit_gateway_id":
replaceOpts = &ec2.ReplaceRouteInput{
RouteTableId: aws.String(d.Get("route_table_id").(string)),
DestinationCidrBlock: aws.String(d.Get("destination_cidr_block").(string)),
TransitGatewayId: aws.String(d.Get("transit_gateway_id").(string)),
RouteTableId: aws.String(d.Get("route_table_id").(string)),
TransitGatewayId: aws.String(d.Get("transit_gateway_id").(string)),
}
if v, ok := d.GetOk("destination_cidr_block"); ok {
replaceOpts.DestinationCidrBlock = aws.String(v.(string))
}

if v, ok := d.GetOk("destination_ipv6_cidr_block"); ok {
replaceOpts.DestinationIpv6CidrBlock = aws.String(v.(string))
}
case "vpc_peering_connection_id":
replaceOpts = &ec2.ReplaceRouteInput{
RouteTableId: aws.String(d.Get("route_table_id").(string)),
DestinationCidrBlock: aws.String(d.Get("destination_cidr_block").(string)),
VpcPeeringConnectionId: aws.String(d.Get("vpc_peering_connection_id").(string)),
}
if v, ok := d.GetOk("destination_cidr_block"); ok {
replaceOpts.DestinationCidrBlock = aws.String(v.(string))
}

if v, ok := d.GetOk("destination_ipv6_cidr_block"); ok {
replaceOpts.DestinationIpv6CidrBlock = aws.String(v.(string))
}
default:
return fmt.Errorf("An invalid target type specified: %s", setTarget)
}
Expand Down