-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #119 from cloudgraphdev/alpha
Beta release
- Loading branch information
Showing
29 changed files
with
615 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import isEmpty from 'lodash/isEmpty' | ||
|
||
import { | ||
Volume, | ||
Snapshot, | ||
TagList, | ||
} from 'aws-sdk/clients/ec2' | ||
|
||
import { ServiceConnection } from '@cloudgraph/sdk' | ||
|
||
import services from '../../enums/services' | ||
|
||
/** | ||
* EBS | ||
*/ | ||
|
||
export default ({ | ||
service: volume, | ||
data, | ||
region, | ||
account, | ||
}: { | ||
account: string | ||
data: { name: string; data: { [property: string]: any[] } }[] | ||
service: Volume & { | ||
region: string | ||
Tags?: TagList | ||
} | ||
region: string | ||
}): { [key: string]: ServiceConnection[] } => { | ||
const connections: ServiceConnection[] = [] | ||
|
||
const { | ||
VolumeId: id, | ||
SnapshotId: snapshotId, | ||
} = volume | ||
|
||
/** | ||
* Find EBS Snapshot | ||
* related to this EBS Volume | ||
*/ | ||
const ebsSnapshots: { | ||
name: string | ||
data: { [property: string]: Snapshot[] } | ||
} = data.find(({ name }) => name === services.ebsSnapshot) | ||
|
||
if (ebsSnapshots?.data?.[region]) { | ||
const snapshotInRegion: Snapshot[] = ebsSnapshots.data[region].filter( | ||
({ SnapshotId }: Snapshot) => SnapshotId === snapshotId | ||
) | ||
|
||
if (!isEmpty(snapshotInRegion)) { | ||
for (const sh of snapshotInRegion) { | ||
connections.push({ | ||
id: sh.SnapshotId, | ||
resourceType: services.ebsSnapshot, | ||
relation: 'child', | ||
field: 'ebsSnapshots', | ||
}) | ||
} | ||
} | ||
} | ||
|
||
const ebsResult = { | ||
[id]: connections, | ||
} | ||
return ebsResult | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import isEmpty from 'lodash/isEmpty' | ||
|
||
import { | ||
Snapshot, | ||
TagList, | ||
} from 'aws-sdk/clients/ec2' | ||
|
||
import { ServiceConnection } from '@cloudgraph/sdk' | ||
|
||
import services from '../../enums/services' | ||
|
||
|
||
/** | ||
* EBS Snapshot | ||
*/ | ||
|
||
export default ({ | ||
service: snapshot, | ||
data, | ||
region, | ||
account, | ||
}: { | ||
account: string | ||
data: { name: string; data: { [property: string]: any[] } }[] | ||
service: Snapshot & { | ||
region: string | ||
Tags?: TagList | ||
} | ||
region: string | ||
}): { [key: string]: ServiceConnection[] } => { | ||
const connections: ServiceConnection[] = [] | ||
|
||
const { | ||
SnapshotId: id, | ||
KmsKeyId: kmsKeyId, | ||
} = snapshot | ||
|
||
/** | ||
* Find KMS | ||
* related to the cloudTrail | ||
*/ | ||
const kmsKeys = data.find(({ name }) => name === services.kms) | ||
if (kmsKeys?.data?.[region]) { | ||
const kmsKeyInRegion = kmsKeys.data[region].filter( | ||
kmsKey => kmsKey.Arn === kmsKeyId | ||
) | ||
|
||
if (!isEmpty(kmsKeyInRegion)) { | ||
for (const kms of kmsKeyInRegion) { | ||
connections.push({ | ||
id: kms.KeyId, | ||
resourceType: services.kms, | ||
relation: 'child', | ||
field: 'kms', | ||
}) | ||
} | ||
} | ||
} | ||
|
||
const snapshotResult = { | ||
[id]: connections, | ||
} | ||
return snapshotResult | ||
} |
Oops, something went wrong.