Merge pull request #853 from cloudskiff/enrich_aws_route

Add origin to `aws_route` in enumerator
main
Elie 2021-07-20 14:27:48 +02:00 committed by GitHub
commit 2ac36fd416
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 0 deletions

View File

@ -36,6 +36,7 @@ func (e *EC2RouteEnumerator) Enumerate() ([]resource.Resource, error) {
routeId, _ := aws.CalculateRouteID(routeTable.RouteTableId, route.DestinationCidrBlock, route.DestinationIpv6CidrBlock) routeId, _ := aws.CalculateRouteID(routeTable.RouteTableId, route.DestinationCidrBlock, route.DestinationIpv6CidrBlock)
data := map[string]interface{}{ data := map[string]interface{}{
"route_table_id": *routeTable.RouteTableId, "route_table_id": *routeTable.RouteTableId,
"origin": *route.Origin,
} }
if route.DestinationCidrBlock != nil && *route.DestinationCidrBlock != "" { if route.DestinationCidrBlock != nil && *route.DestinationCidrBlock != "" {
data["destination_cidr_block"] = *route.DestinationCidrBlock data["destination_cidr_block"] = *route.DestinationCidrBlock

View File

@ -1850,10 +1850,12 @@ func TestEC2Route(t *testing.T) {
{ {
DestinationCidrBlock: awssdk.String("1.1.1.1/32"), DestinationCidrBlock: awssdk.String("1.1.1.1/32"),
GatewayId: awssdk.String("igw-030e74f73bd67f21b"), GatewayId: awssdk.String("igw-030e74f73bd67f21b"),
Origin: awssdk.String("CreateRoute"),
}, },
{ {
DestinationIpv6CidrBlock: awssdk.String("::/0"), DestinationIpv6CidrBlock: awssdk.String("::/0"),
GatewayId: awssdk.String("igw-030e74f73bd67f21b"), GatewayId: awssdk.String("igw-030e74f73bd67f21b"),
Origin: awssdk.String("CreateRoute"),
}, },
}, },
}, },
@ -1867,10 +1869,12 @@ func TestEC2Route(t *testing.T) {
{ {
DestinationCidrBlock: awssdk.String("0.0.0.0/0"), DestinationCidrBlock: awssdk.String("0.0.0.0/0"),
GatewayId: awssdk.String("igw-030e74f73bd67f21b"), GatewayId: awssdk.String("igw-030e74f73bd67f21b"),
Origin: awssdk.String("CreateRoute"),
}, },
{ {
DestinationIpv6CidrBlock: awssdk.String("::/0"), DestinationIpv6CidrBlock: awssdk.String("::/0"),
GatewayId: awssdk.String("igw-030e74f73bd67f21b"), GatewayId: awssdk.String("igw-030e74f73bd67f21b"),
Origin: awssdk.String("CreateRoute"),
}, },
}, },
}, },
@ -1890,10 +1894,12 @@ func TestEC2Route(t *testing.T) {
{ {
DestinationCidrBlock: awssdk.String("10.1.1.0/24"), DestinationCidrBlock: awssdk.String("10.1.1.0/24"),
GatewayId: awssdk.String("igw-030e74f73bd67f21b"), GatewayId: awssdk.String("igw-030e74f73bd67f21b"),
Origin: awssdk.String("CreateRoute"),
}, },
{ {
DestinationCidrBlock: awssdk.String("10.1.2.0/24"), DestinationCidrBlock: awssdk.String("10.1.2.0/24"),
GatewayId: awssdk.String("igw-030e74f73bd67f21b"), GatewayId: awssdk.String("igw-030e74f73bd67f21b"),
Origin: awssdk.String("CreateRoute"),
}, },
}, },
}, },