diff --git a/aws/resource_aws_route.go b/aws/resource_aws_route.go index 85151b08977..ccacd25e4ff 100644 --- a/aws/resource_aws_route.go +++ b/aws/resource_aws_route.go @@ -172,9 +172,17 @@ func resourceAwsRouteCreate(d *schema.ResourceData, meta interface{}) error { case "vpc_peering_connection_id": createOpts = &ec2.CreateRouteInput{ 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 { + createOpts.DestinationCidrBlock = aws.String(v.(string)) + } + + if v, ok := d.GetOk("destination_ipv6_cidr_block"); ok { + createOpts.DestinationIpv6CidrBlock = aws.String(v.(string)) + } + default: return fmt.Errorf("An invalid target type specified: %s", setTarget) } diff --git a/aws/resource_aws_route_test.go b/aws/resource_aws_route_test.go index 24459689bea..1dc50a564db 100644 --- a/aws/resource_aws_route_test.go +++ b/aws/resource_aws_route_test.go @@ -106,6 +106,26 @@ func TestAccAWSRoute_ipv6ToInternetGateway(t *testing.T) { }) } +func TestAccAWSRoute_ipv6ToPeeringConnection(t *testing.T) { + var route ec2.Route + + resource.Test(t, resource.TestCase{ + PreCheck: func() { + testAccPreCheck(t) + }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAWSRouteDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSRouteConfigIpv6PeeringConnection, + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSRouteExists("aws_route.pc", &route), + ), + }, + }, + }) +} + func TestAccAWSRoute_changeCidr(t *testing.T) { var route ec2.Route var routeTable ec2.RouteTable @@ -334,6 +354,35 @@ resource "aws_route" "igw" { `) +var testAccAWSRouteConfigIpv6PeeringConnection = fmt.Sprintf(` +resource "aws_vpc" "foo" { + cidr_block = "10.0.0.0/16" + assign_generated_ipv6_cidr_block = true +} + +resource "aws_vpc" "bar" { + cidr_block = "10.1.0.0/16" + assign_generated_ipv6_cidr_block = true +} + +resource "aws_vpc_peering_connection" "foo" { + vpc_id = "${aws_vpc.foo.id}" + peer_vpc_id = "${aws_vpc.bar.id}" + auto_accept = true +} + +resource "aws_route_table" "peering" { + vpc_id = "${aws_vpc.foo.id}" +} + +resource "aws_route" "pc" { + route_table_id = "${aws_route_table.peering.id}" + destination_ipv6_cidr_block = "${aws_vpc.bar.ipv6_cidr_block}" + vpc_peering_connection_id = "${aws_vpc_peering_connection.foo.id}" +} + +`) + var testAccAWSRouteConfigIpv6 = fmt.Sprintf(` resource "aws_vpc" "foo" { cidr_block = "10.1.0.0/16"