Skip to content

Commit 47be413

Browse files
authored
Merge pull request #75 from cloudgraphdev/feature/CG-1204
feat(services): Add service vpcPeeringConnection
2 parents 24de3a9 + e74e1a6 commit 47be413

18 files changed

Lines changed: 428 additions & 1 deletion

File tree

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,9 @@ CloudGraph AWS Provider will ask you what regions you would like to crawl and wi
161161
| systemsManagerDocument | |
162162
| transitGateway | routeTable, transitGatewayAttachment, vpnConnection |
163163
| transitGatewayAttachment | routeTable, transitGateway, vpc, vpnConnection |
164-
| vpc | alb, codebuild, dmsReplicationInstance, ec2, eip, elb, ecsService, efsMountTarget, eksCluster igw, elastiCacheCluster, elasticSearchDomain, lambda, nacl, natGateway, networkInterface, rdsClusterSnapshot, rdsDbInstance, redshiftCluster, route53HostedZone, routeTable, subnet, flowLog, vpnGateway, transitGatewayAttachment, vpcEndpoint |
164+
| vpc | alb, codebuild, dmsReplicationInstance, ec2, eip, elb, ecsService, efsMountTarget, eksCluster igw, elastiCacheCluster, elasticSearchDomain, lambda, nacl, natGateway, networkInterface, rdsClusterSnapshot, rdsDbInstance, redshiftCluster, route53HostedZone, routeTable, subnet, flowLog, vpnGateway, transitGatewayAttachment, vpcEndpoint, vpcPeeringConnection |
165165
| vpcEndpoint | networkInterface, routeTable, securityGroup, subnet, vpc |
166+
| vpcPeeringConnection | vpc |
166167
| vpnConnection | customerGateway, transitGateway, transitGatewayAttachment, vpnGateway |
167168
| vpnGateway | vpc, vpnConnection |
168169
| wafV2WebAcl | appSync, apiGatewayStage, alb |

src/enums/schemasMap.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ export default {
8080
[services.subnet]: 'awsSubnet',
8181
[services.vpc]: 'awsVpc',
8282
[services.vpcEndpoint]: 'awsVpcEndpoint',
83+
[services.vpcPeeringConnection]: 'awsVpcPeeringConnection',
8384
[services.vpnGateway]: 'awsVpnGateway',
8485
[services.sqs]: 'awsSqs',
8586
[services.rdsCluster]: 'awsRdsCluster',

src/enums/serviceAliases.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,5 @@ export default {
7272
[services.transitGatewayAttachment]: 'transitGatewayAttachments',
7373
[services.vpcEndpoint]: 'vpcEndpoints',
7474
[services.vpnConnection]: 'vpnConnections',
75+
[services.vpcPeeringConnection]: 'vpcPeeringConnections',
7576
}

src/enums/serviceMap.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ import RdsClusterSnapshot from '../services/rdsClusterSnapshot'
9999
import VpcEndpoint from '../services/vpcEndpoint'
100100
import APIGatewayDomainName from '../services/apiGatewayDomainName'
101101
import APIGatewayHttpApi from '../services/apiGatewayHttpApi'
102+
import VpcPeeringConnection from '../services/vpcPeeringConnection'
102103

103104
/**
104105
* serviceMap is an object that contains all currently supported services for AWS
@@ -164,6 +165,7 @@ export default {
164165
[services.subnet]: AwsSubnet,
165166
[services.vpc]: VPC,
166167
[services.vpcEndpoint]: VpcEndpoint,
168+
[services.vpcPeeringConnection]: VpcPeeringConnection,
167169
[services.sqs]: SQS,
168170
[services.rdsCluster]: RDSCluster,
169171
[services.rdsClusterSnapshot]: RdsClusterSnapshot,

src/enums/services.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ export default {
9494
transitGatewayAttachment: 'transitGatewayAttachment',
9595
vpc: 'vpc',
9696
vpcEndpoint: 'vpcEndpoint',
97+
vpcPeeringConnection: 'vpcPeeringConnection',
9798
vpnConnection: 'vpnConnection',
9899
vpnGateway: 'vpnGateway',
99100
wafV2WebAcl: 'wafV2WebAcl',

src/properties/logger.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -676,4 +676,8 @@ export default {
676676
* Access Analyzers
677677
*/
678678
fetchedaccessAnalyzers: (num: number): string => `Found ${num} Access Analyzers`,
679+
/**
680+
* Vpc Peering Connections
681+
*/
682+
fetchedVpcPeeringConnections: (num: number): string => `Found ${num} Vpc Peering Connections`,
679683
}

src/services/account/schema.graphql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ type awsAccount implements awsOptionalService @key(fields: "id") {
9595
transitGatewayAttachments: [awsTransitGatewayAttachment]
9696
vpc: [awsVpc]
9797
vpcEndpoints: [awsVpcEndpoint]
98+
vpcPeeringConnections: [awsVpcPeeringConnection]
9899
vpnConnections: [awsVpnConnection]
99100
vpnGateway: [awsVpnGateway]
100101
wafV2WebAcl: [awsWafV2WebAcl]

src/services/tag/connections.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ import { RawAwsVpcEndpoint } from '../vpcEndpoint/data'
6969
import { RawAwsApiGatewayHttpApi } from '../apiGatewayHttpApi/data'
7070
import { RawAwsApiGatewayDomainName } from '../apiGatewayDomainName/data'
7171
import { RawAwsAnalyzerSummary } from '../iamAccessAnalyzer/data'
72+
import { RawAwsVpcPeeringConnection } from '../vpcPeeringConnection/data'
7273

7374
const findServiceInstancesWithTag = (tag: any, service: any): any => {
7475
const { id } = tag
@@ -1807,6 +1808,32 @@ export default ({
18071808
}
18081809
}
18091810
}
1811+
1812+
/**
1813+
* Find related Vpc Peering Connections
1814+
*/
1815+
const vpcPeeringConnections: {
1816+
name: string
1817+
data: { [property: string]: RawAwsVpcPeeringConnection[] }
1818+
} = data.find(({ name }) => name === services.vpcPeeringConnection)
1819+
if (vpcPeeringConnections?.data?.[region]) {
1820+
const dataAtRegion = findServiceInstancesWithTag(
1821+
tag,
1822+
vpcPeeringConnections.data[region]
1823+
)
1824+
if (!isEmpty(dataAtRegion)) {
1825+
for (const instance of dataAtRegion) {
1826+
const { VpcPeeringConnectionId: id }: RawAwsVpcPeeringConnection = instance
1827+
1828+
connections.push({
1829+
id,
1830+
resourceType: services.vpcPeeringConnection,
1831+
relation: 'child',
1832+
field: 'vpcPeeringConnections',
1833+
})
1834+
}
1835+
}
1836+
}
18101837
}
18111838

18121839
const tagResult = {

src/services/tag/schema.graphql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ type awsTag @key(fields: "id") {
7272
elasticSearchDomains: [awsElasticSearchDomain]
7373
dmsReplicationInstances: [awsDmsReplicationInstance]
7474
systemsManagerDocuments: [awsSystemsManagerDocument]
75+
vpcPeeringConnections: [awsVpcPeeringConnection]
7576
vpcEndpoints: [awsVpcEndpoint]
7677
}
7778

src/services/vpc/schema.graphql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,6 @@ type awsVpc implements awsBaseService @key(fields: "id") {
3232
elasticSearchDomains: [awsElasticSearchDomain] @hasInverse(field: vpc)
3333
dmsReplicationInstances: [awsDmsReplicationInstance] @hasInverse(field: vpc)
3434
rdsClusterSnapshots: [awsRdsClusterSnapshot] @hasInverse(field: vpc)
35+
vpcPeeringConnection: [awsVpcPeeringConnection] @hasInverse(field: vpc)
3536
vpcEndpoints: [awsVpcEndpoint] @hasInverse(field: vpc)
3637
}

0 commit comments

Comments
 (0)