Skip to content

Commit

Permalink
r/aws_route: Add 'local_gateway_id' to attribute checking.
Browse files Browse the repository at this point in the history
  • Loading branch information
ewbankkit committed Sep 6, 2020
1 parent 50234dc commit 275b329
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
4 changes: 2 additions & 2 deletions aws/resource_aws_route.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ func resourceAwsRoute() *schema.Resource {
"local_gateway_id": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},

"instance_id": {
Expand Down Expand Up @@ -436,9 +435,10 @@ var (
"egress_only_gateway_id": {false, true},
"gateway_id": {true, true},
"instance_id": {true, true},
"local_gateway_id": {true, true},
"nat_gateway_id": {true, false},
"network_interface_id": {true, true},
"transit_gateway_id": {true, false},
"transit_gateway_id": {true, true},
"vpc_peering_connection_id": {true, true},
})

Expand Down
23 changes: 23 additions & 0 deletions aws/resource_aws_route_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ func TestGetRouteDestinationAndTargetAttributeKeys(t *testing.T) {
destinationKey: "destination_cidr_block",
targetKey: "transit_gateway_id",
},
{
m: map[string]interface{}{
"destination_ipv6_cidr_block": "::/0",
"transit_gateway_id": "tgw-0000000000000000",
},
destinationKey: "destination_ipv6_cidr_block",
targetKey: "transit_gateway_id",
},
{
m: map[string]interface{}{
"destination_cidr_block": "0.0.0.0/0",
Expand Down Expand Up @@ -647,6 +655,7 @@ func TestAccAWSRoute_IPv4_To_NetworkInterface_TwoAttachments(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "gateway_id", ""),
resource.TestCheckResourceAttrPair(resourceName, "instance_id", instanceResourceName, "id"),
testAccCheckResourceAttrAccountID(resourceName, "instance_owner_id"),
resource.TestCheckResourceAttr(resourceName, "local_gateway_id", ""),
resource.TestCheckResourceAttr(resourceName, "nat_gateway_id", ""),
resource.TestCheckResourceAttrPair(resourceName, "network_interface_id", eni1ResourceName, "id"),
resource.TestCheckResourceAttr(resourceName, "origin", ec2.RouteOriginCreateRoute),
Expand All @@ -666,6 +675,7 @@ func TestAccAWSRoute_IPv4_To_NetworkInterface_TwoAttachments(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "gateway_id", ""),
resource.TestCheckResourceAttrPair(resourceName, "instance_id", instanceResourceName, "id"),
testAccCheckResourceAttrAccountID(resourceName, "instance_owner_id"),
resource.TestCheckResourceAttr(resourceName, "local_gateway_id", ""),
resource.TestCheckResourceAttr(resourceName, "nat_gateway_id", ""),
resource.TestCheckResourceAttrPair(resourceName, "network_interface_id", eni2ResourceName, "id"),
resource.TestCheckResourceAttr(resourceName, "origin", ec2.RouteOriginCreateRoute),
Expand Down Expand Up @@ -1033,6 +1043,7 @@ func TestAccAWSRoute_IPv4_Update_Target(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "gateway_id", ""),
resource.TestCheckResourceAttrPair(resourceName, "instance_id", instanceResourceName, "id"),
testAccCheckResourceAttrAccountID(resourceName, "instance_owner_id"),
resource.TestCheckResourceAttr(resourceName, "local_gateway_id", ""),
resource.TestCheckResourceAttr(resourceName, "nat_gateway_id", ""),
resource.TestCheckResourceAttrPair(resourceName, "network_interface_id", instanceResourceName, "primary_network_interface_id"),
resource.TestCheckResourceAttr(resourceName, "origin", ec2.RouteOriginCreateRoute),
Expand All @@ -1052,6 +1063,7 @@ func TestAccAWSRoute_IPv4_Update_Target(t *testing.T) {
resource.TestCheckResourceAttrPair(resourceName, "gateway_id", vgwResourceName, "id"),
resource.TestCheckResourceAttr(resourceName, "instance_id", ""),
resource.TestCheckResourceAttr(resourceName, "instance_owner_id", ""),
resource.TestCheckResourceAttr(resourceName, "local_gateway_id", ""),
resource.TestCheckResourceAttr(resourceName, "nat_gateway_id", ""),
resource.TestCheckResourceAttr(resourceName, "network_interface_id", ""),
resource.TestCheckResourceAttr(resourceName, "origin", ec2.RouteOriginCreateRoute),
Expand All @@ -1071,6 +1083,7 @@ func TestAccAWSRoute_IPv4_Update_Target(t *testing.T) {
resource.TestCheckResourceAttrPair(resourceName, "gateway_id", igwResourceName, "id"),
resource.TestCheckResourceAttr(resourceName, "instance_id", ""),
resource.TestCheckResourceAttr(resourceName, "instance_owner_id", ""),
resource.TestCheckResourceAttr(resourceName, "local_gateway_id", ""),
resource.TestCheckResourceAttr(resourceName, "nat_gateway_id", ""),
resource.TestCheckResourceAttr(resourceName, "network_interface_id", ""),
resource.TestCheckResourceAttr(resourceName, "origin", ec2.RouteOriginCreateRoute),
Expand All @@ -1090,6 +1103,7 @@ func TestAccAWSRoute_IPv4_Update_Target(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "gateway_id", ""),
resource.TestCheckResourceAttr(resourceName, "instance_id", ""),
resource.TestCheckResourceAttr(resourceName, "instance_owner_id", ""),
resource.TestCheckResourceAttr(resourceName, "local_gateway_id", ""),
resource.TestCheckResourceAttrPair(resourceName, "nat_gateway_id", ngwResourceName, "id"),
resource.TestCheckResourceAttr(resourceName, "network_interface_id", ""),
resource.TestCheckResourceAttr(resourceName, "origin", ec2.RouteOriginCreateRoute),
Expand All @@ -1110,6 +1124,7 @@ func TestAccAWSRoute_IPv4_Update_Target(t *testing.T) {
resource.TestCheckResourceAttrPair(resourceName, "instance_id", instanceResourceName, "id"),
testAccCheckResourceAttrAccountID(resourceName, "instance_owner_id"),
resource.TestCheckResourceAttr(resourceName, "nat_gateway_id", ""),
resource.TestCheckResourceAttr(resourceName, "local_gateway_id", ""),
resource.TestCheckResourceAttrPair(resourceName, "network_interface_id", eniResourceName, "id"),
resource.TestCheckResourceAttr(resourceName, "origin", ec2.RouteOriginCreateRoute),
resource.TestCheckResourceAttr(resourceName, "state", ec2.RouteStateActive),
Expand All @@ -1128,6 +1143,7 @@ func TestAccAWSRoute_IPv4_Update_Target(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "gateway_id", ""),
resource.TestCheckResourceAttr(resourceName, "instance_id", ""),
resource.TestCheckResourceAttr(resourceName, "instance_owner_id", ""),
resource.TestCheckResourceAttr(resourceName, "local_gateway_id", ""),
resource.TestCheckResourceAttr(resourceName, "nat_gateway_id", ""),
resource.TestCheckResourceAttr(resourceName, "network_interface_id", ""),
resource.TestCheckResourceAttr(resourceName, "origin", ec2.RouteOriginCreateRoute),
Expand All @@ -1147,6 +1163,7 @@ func TestAccAWSRoute_IPv4_Update_Target(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "gateway_id", ""),
resource.TestCheckResourceAttr(resourceName, "instance_id", ""),
resource.TestCheckResourceAttr(resourceName, "instance_owner_id", ""),
resource.TestCheckResourceAttr(resourceName, "local_gateway_id", ""),
resource.TestCheckResourceAttr(resourceName, "nat_gateway_id", ""),
resource.TestCheckResourceAttr(resourceName, "network_interface_id", ""),
resource.TestCheckResourceAttr(resourceName, "origin", ec2.RouteOriginCreateRoute),
Expand Down Expand Up @@ -1193,6 +1210,7 @@ func TestAccAWSRoute_IPv6_Update_Target(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "gateway_id", ""),
resource.TestCheckResourceAttrPair(resourceName, "instance_id", instanceResourceName, "id"),
testAccCheckResourceAttrAccountID(resourceName, "instance_owner_id"),
resource.TestCheckResourceAttr(resourceName, "local_gateway_id", ""),
resource.TestCheckResourceAttr(resourceName, "nat_gateway_id", ""),
resource.TestCheckResourceAttrPair(resourceName, "network_interface_id", instanceResourceName, "primary_network_interface_id"),
resource.TestCheckResourceAttr(resourceName, "origin", ec2.RouteOriginCreateRoute),
Expand All @@ -1212,6 +1230,7 @@ func TestAccAWSRoute_IPv6_Update_Target(t *testing.T) {
resource.TestCheckResourceAttrPair(resourceName, "gateway_id", vgwResourceName, "id"),
resource.TestCheckResourceAttr(resourceName, "instance_id", ""),
resource.TestCheckResourceAttr(resourceName, "instance_owner_id", ""),
resource.TestCheckResourceAttr(resourceName, "local_gateway_id", ""),
resource.TestCheckResourceAttr(resourceName, "nat_gateway_id", ""),
resource.TestCheckResourceAttr(resourceName, "network_interface_id", ""),
resource.TestCheckResourceAttr(resourceName, "origin", ec2.RouteOriginCreateRoute),
Expand All @@ -1231,6 +1250,7 @@ func TestAccAWSRoute_IPv6_Update_Target(t *testing.T) {
resource.TestCheckResourceAttrPair(resourceName, "gateway_id", igwResourceName, "id"),
resource.TestCheckResourceAttr(resourceName, "instance_id", ""),
resource.TestCheckResourceAttr(resourceName, "instance_owner_id", ""),
resource.TestCheckResourceAttr(resourceName, "local_gateway_id", ""),
resource.TestCheckResourceAttr(resourceName, "nat_gateway_id", ""),
resource.TestCheckResourceAttr(resourceName, "network_interface_id", ""),
resource.TestCheckResourceAttr(resourceName, "origin", ec2.RouteOriginCreateRoute),
Expand All @@ -1250,6 +1270,7 @@ func TestAccAWSRoute_IPv6_Update_Target(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "gateway_id", ""),
resource.TestCheckResourceAttr(resourceName, "instance_id", ""),
resource.TestCheckResourceAttr(resourceName, "instance_owner_id", ""),
resource.TestCheckResourceAttr(resourceName, "local_gateway_id", ""),
resource.TestCheckResourceAttr(resourceName, "nat_gateway_id", ""),
resource.TestCheckResourceAttr(resourceName, "network_interface_id", ""),
resource.TestCheckResourceAttr(resourceName, "origin", ec2.RouteOriginCreateRoute),
Expand All @@ -1269,6 +1290,7 @@ func TestAccAWSRoute_IPv6_Update_Target(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "gateway_id", ""),
resource.TestCheckResourceAttr(resourceName, "instance_id", ""),
resource.TestCheckResourceAttr(resourceName, "instance_owner_id", ""),
resource.TestCheckResourceAttr(resourceName, "local_gateway_id", ""),
resource.TestCheckResourceAttr(resourceName, "nat_gateway_id", ""),
resource.TestCheckResourceAttrPair(resourceName, "network_interface_id", eniResourceName, "id"),
resource.TestCheckResourceAttr(resourceName, "origin", ec2.RouteOriginCreateRoute),
Expand All @@ -1288,6 +1310,7 @@ func TestAccAWSRoute_IPv6_Update_Target(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "gateway_id", ""),
resource.TestCheckResourceAttr(resourceName, "instance_id", ""),
resource.TestCheckResourceAttr(resourceName, "instance_owner_id", ""),
resource.TestCheckResourceAttr(resourceName, "local_gateway_id", ""),
resource.TestCheckResourceAttr(resourceName, "nat_gateway_id", ""),
resource.TestCheckResourceAttr(resourceName, "network_interface_id", ""),
resource.TestCheckResourceAttr(resourceName, "origin", ec2.RouteOriginCreateRoute),
Expand Down

0 comments on commit 275b329

Please sign in to comment.