Skip to content

Commit d94cbbe

Browse files
committed
Merge branch 'alpha' into feature/CG-1063
2 parents edb8883 + fe254b8 commit d94cbbe

34 files changed

Lines changed: 887 additions & 94 deletions

CHANGELOG.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,40 @@
1+
# [0.79.0-alpha.13](https://github.com/cloudgraphdev/cloudgraph-provider-aws/compare/0.79.0-alpha.12...0.79.0-alpha.13) (2022-04-12)
2+
3+
4+
### Features
5+
6+
* **asg:** add iam role connection ([06285db](https://github.com/cloudgraphdev/cloudgraph-provider-aws/commit/06285db82a8b2feb821d95446e3e0fe87c54cd51))
7+
8+
# [0.79.0-alpha.12](https://github.com/cloudgraphdev/cloudgraph-provider-aws/compare/0.79.0-alpha.11...0.79.0-alpha.12) (2022-04-12)
9+
10+
11+
### Bug Fixes
12+
13+
* add connection between nacl and subnet services ([6ed6dee](https://github.com/cloudgraphdev/cloudgraph-provider-aws/commit/6ed6dee345daa6342f651e5c00bb92178b259954))
14+
15+
# [0.79.0-alpha.11](https://github.com/cloudgraphdev/cloudgraph-provider-aws/compare/0.79.0-alpha.10...0.79.0-alpha.11) (2022-04-12)
16+
17+
18+
### Features
19+
20+
* **s3:** Add connections to iamRole, lambda, sns and sqs services ([1ca01fd](https://github.com/cloudgraphdev/cloudgraph-provider-aws/commit/1ca01fd9b1dabc110b87e0c74e3e63b5c0cb1099))
21+
* **s3:** Add connections to iamRole, lambda, sns and sqs services ([22a8cfd](https://github.com/cloudgraphdev/cloudgraph-provider-aws/commit/22a8cfdbd1365a5b94fdbc91d54886b1135c9682))
22+
23+
# [0.79.0-alpha.10](https://github.com/cloudgraphdev/cloudgraph-provider-aws/compare/0.79.0-alpha.9...0.79.0-alpha.10) (2022-04-12)
24+
25+
26+
### Features
27+
28+
* **cloudFormationStackSet:** add iam role connection ([e25bffb](https://github.com/cloudgraphdev/cloudgraph-provider-aws/commit/e25bffb1f467706ff6a0cc752804a6b3738f6c8b))
29+
30+
# [0.79.0-alpha.9](https://github.com/cloudgraphdev/cloudgraph-provider-aws/compare/0.79.0-alpha.8...0.79.0-alpha.9) (2022-04-12)
31+
32+
33+
### Features
34+
35+
* Handle TODOs for secrets manager ([d7a975d](https://github.com/cloudgraphdev/cloudgraph-provider-aws/commit/d7a975dc2a5ffdb784eef36c4a827d553e7ac1c3))
36+
* Update README file ([0ddf442](https://github.com/cloudgraphdev/cloudgraph-provider-aws/commit/0ddf44211fe3f324371e6a21c6d5df3bc69facfb))
37+
138
# [0.79.0-alpha.8](https://github.com/cloudgraphdev/cloudgraph-provider-aws/compare/0.79.0-alpha.7...0.79.0-alpha.8) (2022-04-11)
239

340

README.md

Lines changed: 9 additions & 9 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.8",
3+
"version": "0.79.0-alpha.13",
44
"description": "cloud-graph provider plugin for AWS used to fetch AWS cloud data.",
55
"publishConfig": {
66
"registry": "https://registry.npmjs.org/",

src/properties/logger.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,7 @@ export default {
427427
gettingRotationStatus: 'Checking rotation status for each key...',
428428
gettingPolicies: 'Fetching default Policy for each key...',
429429
gettingTags: 'Fetching Tags for each key...',
430+
gettingAliases: 'Fetching Aliases for each key...',
430431

431432
/**
432433
* EKS

src/services/asg/connections.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import { SecurityGroup, Volume } from 'aws-sdk/clients/ec2'
1010
import { isEmpty } from 'lodash'
1111
import services from '../../enums/services'
1212
import { RawAwsSubnet } from '../subnet/data'
13+
import { RawAwsIamRole } from '../iamRole/data'
14+
import { globalRegionName } from '../../enums/regions'
1315

1416
/**
1517
* ASG
@@ -34,6 +36,7 @@ export default ({
3436
AutoScalingGroupARN: id,
3537
Instances: instances = [],
3638
VPCZoneIdentifier: commaSeparatedSubnetIds = '',
39+
ServiceLinkedRoleARN: roleArn,
3740
} = asg
3841

3942
const { SecurityGroups: sgIds = [] } = asg.LaunchConfiguration
@@ -142,6 +145,29 @@ export default ({
142145
}
143146
}
144147

148+
/**
149+
* Find related IAM Roles
150+
*/
151+
const roles: { name: string; data: { [property: string]: any[] } } =
152+
data.find(({ name }) => name === services.iamRole)
153+
if (roles?.data?.[globalRegionName]) {
154+
const dataAtRegion: RawAwsIamRole[] = roles.data[globalRegionName].filter(
155+
role => role.Arn === roleArn
156+
)
157+
if (!isEmpty(dataAtRegion)) {
158+
for (const instance of dataAtRegion) {
159+
const { Arn: arn }: RawAwsIamRole = instance
160+
161+
connections.push({
162+
id: arn,
163+
resourceType: services.iamRole,
164+
relation: 'child',
165+
field: 'iamRole',
166+
})
167+
}
168+
}
169+
}
170+
145171
const asgResult = {
146172
[id]: connections,
147173
}

src/services/asg/schema.graphql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,4 +134,5 @@ type awsAsg implements awsBaseService @key(fields: "arn") {
134134
securityGroups: [awsSecurityGroup] @hasInverse(field: asg)
135135
ebs: [awsEbs] @hasInverse(field: asg)
136136
subnet: [awsSubnet] @hasInverse(field: asg) #change to plural
137+
iamRole: [awsIamRole] @hasInverse(field: asg)
137138
}
Lines changed: 56 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,60 @@
1-
// TODO: Enable when IAM is added
2-
// import { ServiceConnection } from '@cloudgraph/sdk';
3-
// import { Stack } from 'aws-sdk/clients/cloudformation';
4-
// import { TagMap } from '../../types'
1+
import isEmpty from 'lodash/isEmpty'
2+
import { ServiceConnection } from '@cloudgraph/sdk';
3+
import { StackSet } from 'aws-sdk/clients/cloudformation';
4+
import { TagMap } from '../../types'
5+
import services from '../../enums/services'
6+
import { RawAwsIamRole } from '../iamRole/data'
7+
import { globalRegionName } from '../../enums/regions'
58

6-
// /**
7-
// * Cloud Formation StackSet
8-
// */
9+
/**
10+
* Cloud Formation StackSet
11+
*/
912

10-
// export default ({
11-
// service: cfStackSet,
12-
// data,
13-
// region,
14-
// }: {
15-
// data: { name: string; data: { [property: string]: any[] } }[]
16-
// service: Stack & {
17-
// region: string
18-
// Tags: TagMap,
19-
// },
20-
// region: string
21-
// }): { [key: string]: ServiceConnection[] } => {
22-
// const connections: ServiceConnection[] = []
13+
export default ({
14+
service: cfStackSet,
15+
data,
16+
region,
17+
}: {
18+
data: { name: string; data: { [property: string]: any[] } }[]
19+
service: StackSet & {
20+
region: string
21+
Tags: TagMap,
22+
},
23+
region: string
24+
}): { [key: string]: ServiceConnection[] } => {
25+
const connections: ServiceConnection[] = []
2326

24-
// const {
25-
// StackId: id,
26-
// // TODO add connection role
27-
// // AdministrationRoleARN: administrationRoleARN
28-
// } = cfStackSet
27+
const {
28+
StackSetId: id,
29+
AdministrationRoleARN: administrationRoleARN,
30+
ExecutionRoleName: executionRoleName,
31+
} = cfStackSet
2932

30-
// const cfStackSetResult = {
31-
// [id]: connections,
32-
// }
33-
// return cfStackSetResult
34-
// }
33+
/**
34+
* Find related IAM Roles
35+
*/
36+
const roles: { name: string; data: { [property: string]: any[] } } =
37+
data.find(({ name }) => name === services.iamRole)
38+
if (roles?.data?.[globalRegionName]) {
39+
const dataAtRegion: RawAwsIamRole[] = roles.data[globalRegionName].filter(
40+
role => role.Arn === administrationRoleARN || role.RoleName === executionRoleName
41+
)
42+
if (!isEmpty(dataAtRegion)) {
43+
for (const instance of dataAtRegion) {
44+
const { Arn: arn }: RawAwsIamRole = instance
45+
46+
connections.push({
47+
id: arn,
48+
resourceType: services.iamRole,
49+
relation: 'child',
50+
field: 'iamRoles',
51+
})
52+
}
53+
}
54+
}
55+
56+
const cfStackSetResult = {
57+
[id]: connections,
58+
}
59+
return cfStackSetResult
60+
}

src/services/cloudFormationStackSet/index.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +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'
5+
import getConnections from './connections'
66
import mutation from './mutation';
77

88
export default class AwsCloudFormation extends BaseService implements Service {
99
format = format.bind(this);
1010

1111
getData = getData.bind(this);
1212

13-
// TODO: Enable when IAM is added
14-
// getConnections = getConnections.bind(this)
13+
getConnections = getConnections.bind(this)
1514

1615
mutation = mutation;
1716
}

src/services/cloudFormationStackSet/schema.graphql

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ type awsCloudFormationStackAutoDeploymentConfig {
4040
enabled: String @search(by: [hash, regexp])
4141
retainStacksOnAccountRemoval: String @search(by: [hash, regexp])
4242
}
43-
# TODO: add accountId to cloudFormationStackSet
43+
4444
type awsCloudFormationStackSet implements awsBaseService @key(fields: "arn") {
4545
name: String @search(by: [hash, regexp])
4646
description: String @search(by: [hash, regexp])
@@ -55,6 +55,5 @@ type awsCloudFormationStackSet implements awsBaseService @key(fields: "arn") {
5555
autoDeploymentConfig: awsCloudFormationStackAutoDeploymentConfig
5656
permissionModel: String @search(by: [hash, regexp])
5757
organizationalUnitIds: [String] @search
58+
iamRoles: [awsIamRole] @hasInverse(field: cloudFormationStackSet)
5859
}
59-
60-
# TODO: add iam role connection using AdministrationRoleARN (also see if a connection can be made using ExecutionRoleName)

src/services/cloudfront/schema.graphql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ type awsCloudfront implements awsBaseService @key(fields: "id") {
1818
origins: [awsCloudfrontOriginData]
1919
logging: awsCloudfrontLoggingConfig
2020
elb: [awsElb] @hasInverse(field: cloudfrontDistribution)
21-
s3: [awsS3] @hasInverse(field: cloudfrontDistribution)
21+
s3: [awsS3] @hasInverse(field: cloudfrontDistributions)
2222
tags: [awsRawTag]
2323
webAcl: [awsWafV2WebAcl] @hasInverse(field: cloudfront)
2424
}

0 commit comments

Comments
 (0)