File tree Expand file tree Collapse file tree 5 files changed +70
-3
lines changed
Expand file tree Collapse file tree 5 files changed +70
-3
lines changed Original file line number Diff line number Diff line change 11import isEmpty from 'lodash/isEmpty'
22
3- import EC2 , {
3+ import {
44 Volume ,
55 Snapshot ,
66 TagList ,
@@ -10,7 +10,6 @@ import { ServiceConnection } from '@cloudgraph/sdk'
1010
1111import services from '../../enums/services'
1212
13-
1413/**
1514 * EBS
1615 */
@@ -34,7 +33,6 @@ export default ({
3433 const {
3534 VolumeId : id ,
3635 SnapshotId : snapshotId ,
37- Tags : tags ,
3836 } = volume
3937
4038 /**
Original file line number Diff line number Diff line change 1+ import isEmpty from 'lodash/isEmpty'
2+
3+ import {
4+ Snapshot ,
5+ TagList ,
6+ } from 'aws-sdk/clients/ec2'
7+
8+ import { ServiceConnection } from '@cloudgraph/sdk'
9+
10+ import services from '../../enums/services'
11+
12+
13+ /**
14+ * EBS Snapshot
15+ */
16+
17+ export default ( {
18+ service : snapshot ,
19+ data,
20+ region,
21+ account,
22+ } : {
23+ account : string
24+ data : { name : string ; data : { [ property : string ] : any [ ] } } [ ]
25+ service : Snapshot & {
26+ region : string
27+ Tags ?: TagList
28+ }
29+ region : string
30+ } ) : { [ key : string ] : ServiceConnection [ ] } => {
31+ const connections : ServiceConnection [ ] = [ ]
32+
33+ const {
34+ SnapshotId : id ,
35+ KmsKeyId : kmsKeyId ,
36+ } = snapshot
37+
38+ /**
39+ * Find KMS
40+ * related to the cloudTrail
41+ */
42+ const kmsKeys = data . find ( ( { name } ) => name === services . kms )
43+ if ( kmsKeys ?. data ?. [ region ] ) {
44+ const kmsKeyInRegion = kmsKeys . data [ region ] . filter (
45+ kmsKey => kmsKey . Arn === kmsKeyId
46+ )
47+
48+ if ( ! isEmpty ( kmsKeyInRegion ) ) {
49+ for ( const kms of kmsKeyInRegion ) {
50+ connections . push ( {
51+ id : kms . KeyId ,
52+ resourceType : services . kms ,
53+ relation : 'child' ,
54+ field : 'kms' ,
55+ } )
56+ }
57+ }
58+ }
59+
60+ const snapshotResult = {
61+ [ id ] : connections ,
62+ }
63+ return snapshotResult
64+ }
Original file line number Diff line number Diff line change @@ -2,12 +2,15 @@ import { Service } from '@cloudgraph/sdk'
22import BaseService from '../base'
33import format from './format'
44import getData from './data'
5+ import getConnections from './connections'
56import mutation from './mutation'
67
78export default class EBSSnapshot extends BaseService implements Service {
89 format = format . bind ( this )
910
1011 getData = getData . bind ( this )
1112
13+ getConnections = getConnections . bind ( this )
14+
1215 mutation = mutation
1316}
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ type awsEbsSnapshot implements awsBaseService @key(fields: "arn") {
1717 storageTier : String @search (by : [hash , regexp ])
1818 restoreExpiryTime : String @search (by : [hash , regexp ])
1919 ebs : [awsEbs ] @hasInverse (field : ebsSnapshots )
20+ kms : [awsKms ] @hasInverse (field : ebsSnapshots )
2021}
2122
2223type awsEbsPermission
Original file line number Diff line number Diff line change @@ -52,4 +52,5 @@ type awsKms implements awsBaseService @key(fields: "id") {
5252 rdsDbInstance : [awsRdsDbInstance ] @hasInverse (field : kms )
5353 managedAirflows : [awsManagedAirflow ] @hasInverse (field : kms )
5454 s3 : [awsS3 ] @hasInverse (field : kms )
55+ ebsSnapshots : [awsEbsSnapshot ] @hasInverse (field : kms )
5556}
You can’t perform that action at this time.
0 commit comments