diff --git a/internal/service/ec2/route_data_source.go b/internal/service/ec2/route_data_source.go index 3f70b064d8b9..b25f071a2393 100644 --- a/internal/service/ec2/route_data_source.go +++ b/internal/service/ec2/route_data_source.go @@ -58,11 +58,6 @@ func DataSourceRoute() *schema.Resource { Optional: true, Computed: true, }, - "instance_id": { - Type: schema.TypeString, - Optional: true, - Computed: true, - }, "local_gateway_id": { Type: schema.TypeString, Optional: true, @@ -140,10 +135,6 @@ func dataSourceRouteRead(d *schema.ResourceData, meta interface{}) error { continue } - if v, ok := d.GetOk("instance_id"); ok && aws.StringValue(r.InstanceId) != v.(string) { - continue - } - if v, ok := d.GetOk("local_gateway_id"); ok && aws.StringValue(r.LocalGatewayId) != v.(string) { continue } @@ -191,7 +182,6 @@ func dataSourceRouteRead(d *schema.ResourceData, meta interface{}) error { d.Set("destination_prefix_list_id", route.DestinationPrefixListId) d.Set("egress_only_gateway_id", route.EgressOnlyInternetGatewayId) d.Set("gateway_id", route.GatewayId) - d.Set("instance_id", route.InstanceId) d.Set("local_gateway_id", route.LocalGatewayId) d.Set("nat_gateway_id", route.NatGatewayId) d.Set("network_interface_id", route.NetworkInterfaceId) diff --git a/internal/service/ec2/route_data_source_test.go b/internal/service/ec2/route_data_source_test.go index 789aac320eb2..ed1e2b6ae7a0 100644 --- a/internal/service/ec2/route_data_source_test.go +++ b/internal/service/ec2/route_data_source_test.go @@ -15,11 +15,9 @@ func TestAccEC2RouteDataSource_basic(t *testing.T) { instanceRouteResourceName := "aws_route.instance" pcxRouteResourceName := "aws_route.vpc_peering_connection" rtResourceName := "aws_route_table.test" - instanceResourceName := "aws_instance.test" pcxResourceName := "aws_vpc_peering_connection.test" datasource1Name := "data.aws_route.by_destination_cidr_block" - datasource2Name := "data.aws_route.by_instance_id" - datasource3Name := "data.aws_route.by_peering_connection_id" + datasource2Name := "data.aws_route.by_peering_connection_id" rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resource.ParallelTest(t, resource.TestCase{ @@ -34,15 +32,10 @@ func TestAccEC2RouteDataSource_basic(t *testing.T) { resource.TestCheckResourceAttrPair(datasource1Name, "destination_cidr_block", instanceRouteResourceName, "destination_cidr_block"), resource.TestCheckResourceAttrPair(datasource1Name, "route_table_id", rtResourceName, "id"), - // By instance ID. - resource.TestCheckResourceAttrPair(datasource2Name, "destination_cidr_block", instanceRouteResourceName, "destination_cidr_block"), - resource.TestCheckResourceAttrPair(datasource2Name, "instance_id", instanceResourceName, "id"), - resource.TestCheckResourceAttrPair(datasource2Name, "route_table_id", rtResourceName, "id"), - // By VPC peering connection ID. - resource.TestCheckResourceAttrPair(datasource3Name, "destination_cidr_block", pcxRouteResourceName, "destination_cidr_block"), - resource.TestCheckResourceAttrPair(datasource3Name, "route_table_id", rtResourceName, "id"), - resource.TestCheckResourceAttrPair(datasource3Name, "vpc_peering_connection_id", pcxResourceName, "id"), + resource.TestCheckResourceAttrPair(datasource2Name, "destination_cidr_block", pcxRouteResourceName, "destination_cidr_block"), + resource.TestCheckResourceAttrPair(datasource2Name, "route_table_id", rtResourceName, "id"), + resource.TestCheckResourceAttrPair(datasource2Name, "vpc_peering_connection_id", pcxResourceName, "id"), ), }, }, @@ -263,12 +256,6 @@ resource "aws_instance" "test" { } } -resource "aws_route" "instance" { - route_table_id = aws_route_table.test.id - destination_cidr_block = "10.0.1.0/24" - instance_id = aws_instance.test.id -} - data "aws_route" "by_peering_connection_id" { route_table_id = aws_route_table.test.id vpc_peering_connection_id = aws_route.vpc_peering_connection.vpc_peering_connection_id @@ -278,11 +265,6 @@ data "aws_route" "by_destination_cidr_block" { route_table_id = aws_route_table.test.id destination_cidr_block = aws_route.instance.destination_cidr_block } - -data "aws_route" "by_instance_id" { - route_table_id = aws_route_table.test.id - instance_id = aws_route.instance.instance_id -} `, rName)) } diff --git a/internal/service/ec2/route_table.go b/internal/service/ec2/route_table.go index fd40abb9f7cb..eb6c30ae5dae 100644 --- a/internal/service/ec2/route_table.go +++ b/internal/service/ec2/route_table.go @@ -30,7 +30,6 @@ var routeTableValidTargets = []string{ "carrier_gateway_id", "egress_only_gateway_id", "gateway_id", - "instance_id", "local_gateway_id", "nat_gateway_id", "network_interface_id", @@ -120,10 +119,6 @@ func ResourceRouteTable() *schema.Resource { Type: schema.TypeString, Optional: true, }, - "instance_id": { - Type: schema.TypeString, - Optional: true, - }, "local_gateway_id": { Type: schema.TypeString, Optional: true, @@ -445,12 +440,6 @@ func resourceRouteTableHash(v interface{}) int { buf.WriteString(fmt.Sprintf("%s-", v.(string))) } - instanceSet := false - if v, ok := m["instance_id"]; ok { - instanceSet = v.(string) != "" - buf.WriteString(fmt.Sprintf("%s-", v.(string))) - } - if v, ok := m["transit_gateway_id"]; ok { buf.WriteString(fmt.Sprintf("%s-", v.(string))) } @@ -467,7 +456,7 @@ func resourceRouteTableHash(v interface{}) int { buf.WriteString(fmt.Sprintf("%s-", v.(string))) } - if v, ok := m["network_interface_id"]; ok && !(instanceSet || natGatewaySet) { + if v, ok := m["network_interface_id"]; ok && !(natGatewaySet) { buf.WriteString(fmt.Sprintf("%s-", v.(string))) } @@ -695,10 +684,6 @@ func expandEc2CreateRouteInput(tfMap map[string]interface{}) *ec2.CreateRouteInp apiObject.GatewayId = aws.String(v) } - if v, ok := tfMap["instance_id"].(string); ok && v != "" { - apiObject.InstanceId = aws.String(v) - } - if v, ok := tfMap["local_gateway_id"].(string); ok && v != "" { apiObject.LocalGatewayId = aws.String(v) } @@ -757,10 +742,6 @@ func expandEc2ReplaceRouteInput(tfMap map[string]interface{}) *ec2.ReplaceRouteI apiObject.GatewayId = aws.String(v) } - if v, ok := tfMap["instance_id"].(string); ok && v != "" { - apiObject.InstanceId = aws.String(v) - } - if v, ok := tfMap["local_gateway_id"].(string); ok && v != "" { apiObject.LocalGatewayId = aws.String(v) } @@ -823,10 +804,6 @@ func flattenEc2Route(apiObject *ec2.Route) map[string]interface{} { } } - if v := apiObject.InstanceId; v != nil { - tfMap["instance_id"] = aws.StringValue(v) - } - if v := apiObject.LocalGatewayId; v != nil { tfMap["local_gateway_id"] = aws.StringValue(v) } diff --git a/internal/service/ec2/route_table_data_source.go b/internal/service/ec2/route_table_data_source.go index 7a0be6d5dd58..902d081a7cb0 100644 --- a/internal/service/ec2/route_table_data_source.go +++ b/internal/service/ec2/route_table_data_source.go @@ -81,11 +81,6 @@ func DataSourceRouteTable() *schema.Resource { Computed: true, }, - "instance_id": { - Type: schema.TypeString, - Computed: true, - }, - "local_gateway_id": { Type: schema.TypeString, Computed: true, @@ -301,9 +296,6 @@ func dataSourceRoutesRead(conn *ec2.EC2, ec2Routes []*ec2.Route) []map[string]in if r.LocalGatewayId != nil { m["local_gateway_id"] = *r.LocalGatewayId } - if r.InstanceId != nil { - m["instance_id"] = *r.InstanceId - } if r.TransitGatewayId != nil { m["transit_gateway_id"] = *r.TransitGatewayId } diff --git a/internal/service/ec2/route_table_test.go b/internal/service/ec2/route_table_test.go index 64515a253752..a70f6caff36a 100644 --- a/internal/service/ec2/route_table_test.go +++ b/internal/service/ec2/route_table_test.go @@ -102,7 +102,6 @@ func TestAccEC2RouteTable_ipv4ToInternetGateway(t *testing.T) { rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) destinationCidr1 := "10.2.0.0/16" destinationCidr2 := "10.3.0.0/16" - destinationCidr3 := "10.4.0.0/16" resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { acctest.PreCheck(t) }, @@ -126,7 +125,7 @@ func TestAccEC2RouteTable_ipv4ToInternetGateway(t *testing.T) { ), }, { - Config: testAccRouteTableIPv4InternetGatewayConfig(rName, destinationCidr2, destinationCidr3), + Config: testAccRouteTableIPv4InternetGatewayConfig(rName, destinationCidr2, destinationCidr2), Check: resource.ComposeTestCheckFunc( testAccCheckRouteTableExists(resourceName, &routeTable), testAccCheckRouteTableNumberOfRoutes(&routeTable, 3), @@ -135,7 +134,7 @@ func TestAccEC2RouteTable_ipv4ToInternetGateway(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "propagating_vgws.#", "0"), resource.TestCheckResourceAttr(resourceName, "route.#", "2"), testAccCheckRouteTableRoute(resourceName, "cidr_block", destinationCidr2, "gateway_id", igwResourceName, "id"), - testAccCheckRouteTableRoute(resourceName, "cidr_block", destinationCidr3, "gateway_id", igwResourceName, "id"), + testAccCheckRouteTableRoute(resourceName, "cidr_block", destinationCidr2, "gateway_id", igwResourceName, "id"), resource.TestCheckResourceAttr(resourceName, "tags.%", "1"), resource.TestCheckResourceAttr(resourceName, "tags.Name", rName), ), @@ -152,7 +151,6 @@ func TestAccEC2RouteTable_ipv4ToInternetGateway(t *testing.T) { func TestAccEC2RouteTable_ipv4ToInstance(t *testing.T) { var routeTable ec2.RouteTable resourceName := "aws_route_table.test" - instanceResourceName := "aws_instance.test" rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) destinationCidr := "10.2.0.0/16" @@ -171,7 +169,6 @@ func TestAccEC2RouteTable_ipv4ToInstance(t *testing.T) { acctest.CheckResourceAttrAccountID(resourceName, "owner_id"), resource.TestCheckResourceAttr(resourceName, "propagating_vgws.#", "0"), resource.TestCheckResourceAttr(resourceName, "route.#", "1"), - testAccCheckRouteTableRoute(resourceName, "cidr_block", destinationCidr, "instance_id", instanceResourceName, "id"), resource.TestCheckResourceAttr(resourceName, "tags.%", "1"), resource.TestCheckResourceAttr(resourceName, "tags.Name", rName), ), @@ -909,13 +906,11 @@ func TestAccEC2RouteTable_multipleRoutes(t *testing.T) { resourceName := "aws_route_table.test" eoigwResourceName := "aws_egress_only_internet_gateway.test" igwResourceName := "aws_internet_gateway.test" - instanceResourceName := "aws_instance.test" pcxResourceName := "aws_vpc_peering_connection.test" rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) destinationCidr1 := "10.2.0.0/16" - destinationCidr2 := "10.3.0.0/16" - destinationCidr3 := "10.4.0.0/16" - destinationCidr4 := "2001:db8::/122" + destinationCidr2 := "10.4.0.0/16" + destinationCidr3 := "2001:db8::/122" resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { acctest.PreCheck(t) }, @@ -926,8 +921,7 @@ func TestAccEC2RouteTable_multipleRoutes(t *testing.T) { { Config: testAccRouteTableMultipleRoutesConfig(rName, "cidr_block", destinationCidr1, "gateway_id", igwResourceName, - "cidr_block", destinationCidr2, "instance_id", instanceResourceName, - "ipv6_cidr_block", destinationCidr4, "egress_only_gateway_id", eoigwResourceName), + "ipv6_cidr_block", destinationCidr3, "egress_only_gateway_id", eoigwResourceName), Check: resource.ComposeTestCheckFunc( testAccCheckRouteTableExists(resourceName, &routeTable), testAccCheckRouteTableNumberOfRoutes(&routeTable, 5), @@ -936,8 +930,7 @@ func TestAccEC2RouteTable_multipleRoutes(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "propagating_vgws.#", "0"), resource.TestCheckResourceAttr(resourceName, "route.#", "3"), testAccCheckRouteTableRoute(resourceName, "cidr_block", destinationCidr1, "gateway_id", igwResourceName, "id"), - testAccCheckRouteTableRoute(resourceName, "cidr_block", destinationCidr2, "instance_id", instanceResourceName, "id"), - testAccCheckRouteTableRoute(resourceName, "ipv6_cidr_block", destinationCidr4, "egress_only_gateway_id", eoigwResourceName, "id"), + testAccCheckRouteTableRoute(resourceName, "ipv6_cidr_block", destinationCidr3, "egress_only_gateway_id", eoigwResourceName, "id"), resource.TestCheckResourceAttr(resourceName, "tags.%", "1"), resource.TestCheckResourceAttr(resourceName, "tags.Name", rName), ), @@ -945,8 +938,7 @@ func TestAccEC2RouteTable_multipleRoutes(t *testing.T) { { Config: testAccRouteTableMultipleRoutesConfig(rName, "cidr_block", destinationCidr1, "vpc_peering_connection_id", pcxResourceName, - "cidr_block", destinationCidr3, "instance_id", instanceResourceName, - "ipv6_cidr_block", destinationCidr4, "egress_only_gateway_id", eoigwResourceName), + "ipv6_cidr_block", destinationCidr3, "egress_only_gateway_id", eoigwResourceName), Check: resource.ComposeTestCheckFunc( testAccCheckRouteTableExists(resourceName, &routeTable), testAccCheckRouteTableNumberOfRoutes(&routeTable, 5), @@ -955,17 +947,15 @@ func TestAccEC2RouteTable_multipleRoutes(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "propagating_vgws.#", "0"), resource.TestCheckResourceAttr(resourceName, "route.#", "3"), testAccCheckRouteTableRoute(resourceName, "cidr_block", destinationCidr1, "vpc_peering_connection_id", pcxResourceName, "id"), - testAccCheckRouteTableRoute(resourceName, "cidr_block", destinationCidr3, "instance_id", instanceResourceName, "id"), - testAccCheckRouteTableRoute(resourceName, "ipv6_cidr_block", destinationCidr4, "egress_only_gateway_id", eoigwResourceName, "id"), + testAccCheckRouteTableRoute(resourceName, "ipv6_cidr_block", destinationCidr3, "egress_only_gateway_id", eoigwResourceName, "id"), resource.TestCheckResourceAttr(resourceName, "tags.%", "1"), resource.TestCheckResourceAttr(resourceName, "tags.Name", rName), ), }, { Config: testAccRouteTableMultipleRoutesConfig(rName, - "ipv6_cidr_block", destinationCidr4, "vpc_peering_connection_id", pcxResourceName, - "cidr_block", destinationCidr3, "gateway_id", igwResourceName, - "cidr_block", destinationCidr2, "instance_id", instanceResourceName), + "ipv6_cidr_block", destinationCidr3, "vpc_peering_connection_id", pcxResourceName, + "cidr_block", destinationCidr2, "gateway_id", igwResourceName), Check: resource.ComposeTestCheckFunc( testAccCheckRouteTableExists(resourceName, &routeTable), testAccCheckRouteTableNumberOfRoutes(&routeTable, 5), @@ -973,9 +963,8 @@ func TestAccEC2RouteTable_multipleRoutes(t *testing.T) { acctest.CheckResourceAttrAccountID(resourceName, "owner_id"), resource.TestCheckResourceAttr(resourceName, "propagating_vgws.#", "0"), resource.TestCheckResourceAttr(resourceName, "route.#", "3"), - testAccCheckRouteTableRoute(resourceName, "ipv6_cidr_block", destinationCidr4, "vpc_peering_connection_id", pcxResourceName, "id"), - testAccCheckRouteTableRoute(resourceName, "cidr_block", destinationCidr3, "gateway_id", igwResourceName, "id"), - testAccCheckRouteTableRoute(resourceName, "cidr_block", destinationCidr2, "instance_id", instanceResourceName, "id"), + testAccCheckRouteTableRoute(resourceName, "ipv6_cidr_block", destinationCidr3, "vpc_peering_connection_id", pcxResourceName, "id"), + testAccCheckRouteTableRoute(resourceName, "cidr_block", destinationCidr2, "gateway_id", igwResourceName, "id"), resource.TestCheckResourceAttr(resourceName, "tags.%", "1"), resource.TestCheckResourceAttr(resourceName, "tags.Name", rName), ), @@ -1333,19 +1322,6 @@ resource "aws_instance" "test" { Name = %[1]q } } - -resource "aws_route_table" "test" { - vpc_id = aws_vpc.test.id - - route { - cidr_block = %[2]q - instance_id = aws_instance.test.id - } - - tags = { - Name = %[1]q - } -} `, rName, destinationCidr)) } @@ -1478,18 +1454,6 @@ func testAccRouteTableConfigNoDestination(rName string) string { acctest.AvailableEC2InstanceTypeForAvailabilityZone("data.aws_availability_zones.available.names[0]", "t3.micro", "t2.micro"), acctest.ConfigLatestAmazonLinuxHvmEbsAmi(), fmt.Sprintf(` -resource "aws_route_table" "test" { - vpc_id = aws_vpc.test.id - - route { - instance_id = aws_instance.test.id - } - - tags = { - Name = %[1]q - } -} - resource "aws_vpc" "test" { cidr_block = "10.1.0.0/16" @@ -2092,8 +2056,7 @@ resource "aws_vpc_endpoint" "test" { func testAccRouteTableMultipleRoutesConfig(rName, destinationAttr1, destinationValue1, targetAttribute1, targetValue1, - destinationAttr2, destinationValue2, targetAttribute2, targetValue2, - destinationAttr3, destinationValue3, targetAttribute3, targetValue3 string) string { + destinationAttr2, destinationValue2, targetAttribute2, targetValue2 string) string { return acctest.ConfigCompose( testAccLatestAmazonNatInstanceAmiConfig(), acctest.ConfigAvailableAZsNoOptInDefaultExclude(), @@ -2176,12 +2139,6 @@ locals { target_attr = %[8]q target_value = %[9]s.id }, - { - destination_attr = %[10]q - destination_value = %[11]q - target_attr = %[12]q - target_value = %[13]s.id - } ] } @@ -2199,7 +2156,6 @@ resource "aws_route_table" "test" { carrier_gateway_id = (route.value["target_attr"] == "carrier_gateway_id") ? route.value["target_value"] : null egress_only_gateway_id = (route.value["target_attr"] == "egress_only_gateway_id") ? route.value["target_value"] : null gateway_id = (route.value["target_attr"] == "gateway_id") ? route.value["target_value"] : null - instance_id = (route.value["target_attr"] == "instance_id") ? route.value["target_value"] : null local_gateway_id = (route.value["target_attr"] == "local_gateway_id") ? route.value["target_value"] : null nat_gateway_id = (route.value["target_attr"] == "nat_gateway_id") ? route.value["target_value"] : null network_interface_id = (route.value["target_attr"] == "network_interface_id") ? route.value["target_value"] : null @@ -2213,7 +2169,7 @@ resource "aws_route_table" "test" { Name = %[1]q } } -`, rName, destinationAttr1, destinationValue1, targetAttribute1, targetValue1, destinationAttr2, destinationValue2, targetAttribute2, targetValue2, destinationAttr3, destinationValue3, targetAttribute3, targetValue3)) +`, rName, destinationAttr1, destinationValue1, targetAttribute1, targetValue1, destinationAttr2, destinationValue2, targetAttribute2, targetValue2)) } // testAccLatestAmazonNatInstanceAmiConfig returns the configuration for a data source that diff --git a/website/docs/d/route.html.markdown b/website/docs/d/route.html.markdown index 38d0c4fdb3f5..6f71b5821a52 100644 --- a/website/docs/d/route.html.markdown +++ b/website/docs/d/route.html.markdown @@ -49,7 +49,6 @@ The following arguments are optional: * `destination_prefix_list_id` - (Optional) The ID of a [managed prefix list](ec2_managed_prefix_list.html) destination of the Route belonging to the Route Table. * `egress_only_gateway_id` - (Optional) Egress Only Gateway ID of the Route belonging to the Route Table. * `gateway_id` - (Optional) Gateway ID of the Route belonging to the Route Table. -* `instance_id` - (Optional) Instance ID of the Route belonging to the Route Table. * `local_gateway_id` - (Optional) Local Gateway ID of the Route belonging to the Route Table. * `nat_gateway_id` - (Optional) NAT Gateway ID of the Route belonging to the Route Table. * `network_interface_id` - (Optional) Network Interface ID of the Route belonging to the Route Table. diff --git a/website/docs/d/route_table.html.markdown b/website/docs/d/route_table.html.markdown index 0f03e35cd4db..3630c4b161fe 100644 --- a/website/docs/d/route_table.html.markdown +++ b/website/docs/d/route_table.html.markdown @@ -76,7 +76,6 @@ For targets: * `carrier_gateway_id` - ID of the Carrier Gateway. * `egress_only_gateway_id` - ID of the Egress Only Internet Gateway. * `gateway_id` - Internet Gateway ID. -* `instance_id` - EC2 instance ID. * `local_gateway_id` - Local Gateway ID. * `nat_gateway_id` - NAT Gateway ID. * `network_interface_id` - ID of the elastic network interface (eni) to use. diff --git a/website/docs/r/route.html.markdown b/website/docs/r/route.html.markdown index 42ca414ded43..2654d59120c8 100644 --- a/website/docs/r/route.html.markdown +++ b/website/docs/r/route.html.markdown @@ -61,7 +61,6 @@ One of the following target arguments must be supplied: * `carrier_gateway_id` - (Optional) Identifier of a carrier gateway. This attribute can only be used when the VPC contains a subnet which is associated with a Wavelength Zone. * `egress_only_gateway_id` - (Optional) Identifier of a VPC Egress Only Internet Gateway. * `gateway_id` - (Optional) Identifier of a VPC internet gateway or a virtual private gateway. -* `instance_id` - (Optional) Identifier of an EC2 instance. * `nat_gateway_id` - (Optional) Identifier of a VPC NAT gateway. * `local_gateway_id` - (Optional) Identifier of a Outpost local gateway. * `network_interface_id` - (Optional) Identifier of an EC2 network interface. diff --git a/website/docs/r/route_table.html.markdown b/website/docs/r/route_table.html.markdown index 37779a3df5a8..9e90ed7560c5 100644 --- a/website/docs/r/route_table.html.markdown +++ b/website/docs/r/route_table.html.markdown @@ -90,7 +90,6 @@ One of the following target arguments must be supplied: * `carrier_gateway_id` - (Optional) Identifier of a carrier gateway. This attribute can only be used when the VPC contains a subnet which is associated with a Wavelength Zone. * `egress_only_gateway_id` - (Optional) Identifier of a VPC Egress Only Internet Gateway. * `gateway_id` - (Optional) Identifier of a VPC internet gateway or a virtual private gateway. -* `instance_id` - (Optional) Identifier of an EC2 instance. * `local_gateway_id` - (Optional) Identifier of a Outpost local gateway. * `nat_gateway_id` - (Optional) Identifier of a VPC NAT gateway. * `network_interface_id` - (Optional) Identifier of an EC2 network interface.