Skip to content

Commit 9a0eab2

Browse files
committed
Merge branch 'alpha' into feature/CG-1063
2 parents 5187b76 + 2eb967a commit 9a0eab2

15 files changed

Lines changed: 268 additions & 113 deletions

File tree

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
# [0.79.0-alpha.7](https://github.com/cloudgraphdev/cloudgraph-provider-aws/compare/0.79.0-alpha.6...0.79.0-alpha.7) (2022-04-11)
2+
3+
4+
### Bug Fixes
5+
6+
* Added iamRole to lambda service ([ae6177d](https://github.com/cloudgraphdev/cloudgraph-provider-aws/commit/ae6177de995975ab5194c5d2fcc8aaf98ec8d06d))
7+
8+
# [0.79.0-alpha.6](https://github.com/cloudgraphdev/cloudgraph-provider-aws/compare/0.79.0-alpha.5...0.79.0-alpha.6) (2022-04-11)
9+
10+
11+
### Features
12+
13+
* Handle TODOs for ecs cluster ([554dff7](https://github.com/cloudgraphdev/cloudgraph-provider-aws/commit/554dff7785dc2c69403a41416c7739625fd02263))
14+
* Update kms connection ([1e3e66d](https://github.com/cloudgraphdev/cloudgraph-provider-aws/commit/1e3e66d41e886bbb39ad9f000167fa93c7313b26))
15+
* Updated README connections ([f536b73](https://github.com/cloudgraphdev/cloudgraph-provider-aws/commit/f536b73f97c1f0ddbea687588e5d10f089fd2500))
16+
117
# [0.79.0-alpha.5](https://github.com/cloudgraphdev/cloudgraph-provider-aws/compare/0.79.0-alpha.4...0.79.0-alpha.5) (2022-04-08)
218

319

README.md

Lines changed: 97 additions & 96 deletions
Large diffs are not rendered by default.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@cloudgraph/cg-provider-aws",
3-
"version": "0.79.0-alpha.5",
3+
"version": "0.79.0-alpha.7",
44
"description": "cloud-graph provider plugin for AWS used to fetch AWS cloud data.",
55
"publishConfig": {
66
"registry": "https://registry.npmjs.org/",

src/services/cloudwatchLogs/schema.graphql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ type awsCloudwatchLog @key(fields: "arn") {
1313
kms: [awsKms] @hasInverse(field: cloudwatchLog)
1414
cloudwatch: [awsCloudwatch] @hasInverse(field: cloudwatchLog)
1515
cloudtrail: [awsCloudtrail] @hasInverse(field: cloudwatchLog)
16+
ecsCluster: [awsEcsCluster] @hasInverse(field: cloudwatchLog)
1617
}
1718

1819
type awsMetricFilter

src/services/cognitoUserPool/connections.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export default ({
103103

104104
if (kmsKeyID && kms?.data?.[region]) {
105105
const kmsInRegion: AwsKms = kms.data[region].find(
106-
({ KeyId }: AwsKms) => kmsKeyID === KeyId
106+
({ KeyArn }: AwsKms) => kmsKeyID === KeyArn
107107
)
108108

109109
if (kmsInRegion) {
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
import { ServiceConnection } from '@cloudgraph/sdk'
2+
3+
import { isEmpty } from 'lodash'
4+
import services from '../../enums/services'
5+
import { RawAwsEcsCluster } from '../ecsCluster/data'
6+
import { RawAwsS3 } from '../s3/data'
7+
import { RawAwsLogGroup } from '../cloudwatchLogs/data'
8+
import { AwsKms } from '../kms/data'
9+
import { gets3BucketId } from '../../utils/ids'
10+
11+
export default ({
12+
service: ecsCluster,
13+
data,
14+
region,
15+
}: {
16+
service: RawAwsEcsCluster
17+
data: Array<{ name: string; data: { [property: string]: any[] } }>
18+
region: string
19+
}): {
20+
[property: string]: ServiceConnection[]
21+
} => {
22+
const {
23+
clusterArn: arn,
24+
configuration: {
25+
executeCommandConfiguration: { logConfiguration, kmsKeyId } = {},
26+
} = {},
27+
} = ecsCluster
28+
const connections: ServiceConnection[] = []
29+
30+
/**
31+
* Find S3
32+
* related to this ecs cluster
33+
*/
34+
const buckets = data.find(({ name }) => name === services.s3)
35+
if (buckets?.data?.[region]) {
36+
const dataAtRegion: RawAwsS3[] = buckets.data[region].filter(
37+
({ Name: name }: RawAwsS3) => name === logConfiguration?.s3BucketName
38+
)
39+
for (const bucket of dataAtRegion) {
40+
connections.push({
41+
id: gets3BucketId(bucket.Name),
42+
resourceType: services.s3,
43+
relation: 'child',
44+
field: 's3',
45+
})
46+
}
47+
}
48+
49+
/**
50+
* Find Cloudwatch Log Group
51+
* related to this ecs cluster
52+
*/
53+
const logGroups = data.find(({ name }) => name === services.cloudwatchLog)
54+
let logGroupsInRegion: RawAwsLogGroup[] = []
55+
if (logGroups?.data?.[region]) {
56+
logGroupsInRegion = logGroups.data[region].filter(
57+
({ logGroupName }: RawAwsLogGroup) =>
58+
logGroupName === logConfiguration?.cloudWatchLogGroupName
59+
)
60+
}
61+
62+
if (!isEmpty(logGroupsInRegion)) {
63+
for (const logGroup of logGroupsInRegion) {
64+
connections.push({
65+
id: logGroup.logGroupName,
66+
resourceType: services.cloudwatchLog,
67+
relation: 'child',
68+
field: 'cloudwatchLog',
69+
})
70+
}
71+
}
72+
73+
/**
74+
* Find MKS
75+
* related to this ecs cluster
76+
*/
77+
const kms = data.find(({ name }) => name === services.kms)
78+
if (kms?.data?.[region]) {
79+
const kmsInRegion: AwsKms = kms.data[region].find(
80+
({ KeyArn }: AwsKms) => KeyArn === kmsKeyId
81+
)
82+
83+
if (kmsInRegion) {
84+
connections.push({
85+
id: kmsInRegion.KeyId,
86+
resourceType: services.kms,
87+
relation: 'child',
88+
field: 'kms',
89+
})
90+
}
91+
}
92+
93+
const natResult = {
94+
[arn]: connections,
95+
}
96+
return natResult
97+
}

src/services/ecsCluster/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@ import {Service} from '@cloudgraph/sdk'
22
import BaseService from '../base'
33
import format from './format'
44
import getData from './data'
5+
import getConnections from './connections'
56
import mutation from './mutation'
67

78
export default class EcsCluster 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
}

src/services/ecsCluster/schema.graphql

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@ type awsEcsCluster implements awsBaseService @key(fields: "arn") {
1616
ecsService: [awsEcsService] @hasInverse(field: ecsCluster)
1717
ecsTask: [awsEcsTask] @hasInverse(field: ecsCluster)
1818
ecsTaskSet: [awsEcsTaskSet] @hasInverse(field: ecsCluster)
19+
s3: [awsS3] @hasInverse(field: ecsCluster)
20+
cloudwatchLog: [awsCloudwatchLog] @hasInverse(field: ecsCluster)
21+
kms: [awsKms] @hasInverse(field: ecsCluster)
1922
}
2023

21-
#TODO: add connections to cloudwatchLog, s3,
22-
2324
type AwsEcsExecuteCommandLogConfiguration
2425
@generate(
2526
query: { get: false, query: true, aggregate: false }

src/services/iamRole/schema.graphql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,5 @@ type awsIamRole implements awsBaseService @key(fields: "id") {
2828
ec2Instances: [awsEc2] @hasInverse(field: iamRole)
2929
cognitoUserPools: [awsCognitoUserPool] @hasInverse(field: iamRole)
3030
appSync: [awsAppSync] @hasInverse(field: iamRoles)
31+
lambda: [awsLambda] @hasInverse(field: iamRole)
3132
}

src/services/kms/schema.graphql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ type awsKms implements awsBaseService @key(fields: "id") {
2828
sageMakerNotebookInstances: [awsSageMakerNotebookInstance]
2929
@hasInverse(field: kms)
3030
rdsClusterSnapshots: [awsRdsClusterSnapshot] @hasInverse(field: kms)
31+
ecsCluster: [awsEcsCluster] @hasInverse(field: kms)
3132
dynamodb: [awsDynamoDbTable] @hasInverse(field: kms)
3233
cognitoUserPools: [awsCognitoUserPool] @hasInverse(field: kms)
3334
}

0 commit comments

Comments
 (0)