Skip to content

Commit f96f486

Browse files
committed
Merge branch 'alpha' into feature/CG-1073
2 parents cae984c + bb27a44 commit f96f486

56 files changed

Lines changed: 1286 additions & 295 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,73 @@
1+
# [0.79.0-alpha.22](https://github.com/cloudgraphdev/cloudgraph-provider-aws/compare/0.79.0-alpha.21...0.79.0-alpha.22) (2022-04-14)
2+
3+
4+
### Bug Fixes
5+
6+
* **elasticSearchDomain:** add cloudwatchLogs, cognitoIdentityPool, cognitoUserPool, iamRole connections ([694d298](https://github.com/cloudgraphdev/cloudgraph-provider-aws/commit/694d298af419a8f18f55ccebb5fc21b06574c930))
7+
8+
# [0.79.0-alpha.21](https://github.com/cloudgraphdev/cloudgraph-provider-aws/compare/0.79.0-alpha.20...0.79.0-alpha.21) (2022-04-14)
9+
10+
11+
### Bug Fixes
12+
13+
* Created iamRole connection for emrCluster ([80a39e1](https://github.com/cloudgraphdev/cloudgraph-provider-aws/commit/80a39e19046ad46a2897f667171b271b5a1f9cc7))
14+
15+
# [0.79.0-alpha.20](https://github.com/cloudgraphdev/cloudgraph-provider-aws/compare/0.79.0-alpha.19...0.79.0-alpha.20) (2022-04-14)
16+
17+
18+
### Features
19+
20+
* **cognitoIdentityPool:** add iamRole/iamOpenIdConnectProvider/iamSamlProvider connections, generate arn ([3ba9610](https://github.com/cloudgraphdev/cloudgraph-provider-aws/commit/3ba9610af535f9b84f229ce6abcfcf1e43664d45))
21+
22+
# [0.79.0-alpha.19](https://github.com/cloudgraphdev/cloudgraph-provider-aws/compare/0.79.0-alpha.18...0.79.0-alpha.19) (2022-04-13)
23+
24+
25+
### Bug Fixes
26+
27+
* Added missing connections to managedAirflow ([dbb9405](https://github.com/cloudgraphdev/cloudgraph-provider-aws/commit/dbb94058dd22c0b538b4f9491e6874031747480f))
28+
29+
# [0.79.0-alpha.18](https://github.com/cloudgraphdev/cloudgraph-provider-aws/compare/0.79.0-alpha.17...0.79.0-alpha.18) (2022-04-13)
30+
31+
32+
### Bug Fixes
33+
34+
* **elasticBeanstalkEnv:** add connections with alb, elb, ec2 and sqs services ([fe21ecd](https://github.com/cloudgraphdev/cloudgraph-provider-aws/commit/fe21ecd924695395dde77a8704bf0e7edcb26c36))
35+
36+
# [0.79.0-alpha.17](https://github.com/cloudgraphdev/cloudgraph-provider-aws/compare/0.79.0-alpha.16...0.79.0-alpha.17) (2022-04-13)
37+
38+
39+
### Bug Fixes
40+
41+
* Added missing connections to RDS DB Instance ([206bd29](https://github.com/cloudgraphdev/cloudgraph-provider-aws/commit/206bd29fd9189d10ab628c07f206e5e6a4725bf6))
42+
43+
44+
### Features
45+
46+
* **rds:** add kms connection cluster/dbInstance ([f501a4e](https://github.com/cloudgraphdev/cloudgraph-provider-aws/commit/f501a4e079503d10841f1af32d3a12f13d277aa2))
47+
* **rdsCluster:** add route53HostedZone connection ([6480e7f](https://github.com/cloudgraphdev/cloudgraph-provider-aws/commit/6480e7f16c404ebb2c7f2f458aa95ae2db93f0dc))
48+
* **rdsCluster:** add subnet connection, add missing properties ([7706a02](https://github.com/cloudgraphdev/cloudgraph-provider-aws/commit/7706a0243384d949f1c4adaf7ec0fa6dd1d4cd57))
49+
50+
# [0.79.0-alpha.16](https://github.com/cloudgraphdev/cloudgraph-provider-aws/compare/0.79.0-alpha.15...0.79.0-alpha.16) (2022-04-13)
51+
52+
53+
### Bug Fixes
54+
55+
* iamInstanceProfile never returning when there's a permission's error ([63e6d4a](https://github.com/cloudgraphdev/cloudgraph-provider-aws/commit/63e6d4a3b8622c5d14a082cc3d9f2eef338c670c))
56+
57+
# [0.79.0-alpha.15](https://github.com/cloudgraphdev/cloudgraph-provider-aws/compare/0.79.0-alpha.14...0.79.0-alpha.15) (2022-04-13)
58+
59+
60+
### Bug Fixes
61+
62+
* add connection between networkInterface and securityGroup services ([8efe2aa](https://github.com/cloudgraphdev/cloudgraph-provider-aws/commit/8efe2aa8e15536df124a666b05d5e08eec8e2f87))
63+
64+
# [0.79.0-alpha.14](https://github.com/cloudgraphdev/cloudgraph-provider-aws/compare/0.79.0-alpha.13...0.79.0-alpha.14) (2022-04-13)
65+
66+
67+
### Bug Fixes
68+
69+
* **elasticBeanstalkApp:** add connection to iamRole, fixes to iamRole ([d5af1af](https://github.com/cloudgraphdev/cloudgraph-provider-aws/commit/d5af1af67656058e42874dd0260b7d1bf63310f5))
70+
171
# [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)
272

373

README.md

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

src/enums/serviceAliases.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export default {
4747
[services.iamUser]: 'iamUsers',
4848
[services.kinesisStream]: 'kinesisStreams',
4949
[services.lambda]: 'lambdaFunctions',
50+
[services.managedAirflow]: 'managedAirflows',
5051
[services.nat]: 'natGateway',
5152
[services.networkInterface]: 'networkInterfaces',
5253
[services.organization]: 'organizations',

src/services/alb/schema.graphql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ type awsAlb implements awsBaseService @key(fields: "arn") {
2121
route53Record: [awsRoute53Record] @hasInverse(field: alb) #change to plural
2222
listeners: [awsAlbListener]
2323
subnet: [awsSubnet] @hasInverse(field: alb) #change to plural
24+
elasticBeanstalkEnvs: [awsElasticBeanstalkEnv] @hasInverse(field: albs)
2425
}
2526

2627
type awsAlbListener

src/services/asg/schema.graphql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ type awsAsg implements awsBaseService @key(fields: "arn") {
131131
tags: [awsRawTag]
132132
launchConfiguration: awsLaunchConfiguration
133133
ec2Instance: [awsEc2] @hasInverse(field: asg) #change to plural
134+
elasticBeanstalkEnvs: [awsElasticBeanstalkEnv] @hasInverse(field: asgs)
134135
securityGroups: [awsSecurityGroup] @hasInverse(field: asg)
135136
ebs: [awsEbs] @hasInverse(field: asg)
136137
subnet: [awsSubnet] @hasInverse(field: asg) #change to plural

src/services/cloudwatchLogs/schema.graphql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ type awsCloudwatchLog @key(fields: "arn") {
1414
cloudwatch: [awsCloudwatch] @hasInverse(field: cloudwatchLog)
1515
cloudtrail: [awsCloudtrail] @hasInverse(field: cloudwatchLog)
1616
ecsCluster: [awsEcsCluster] @hasInverse(field: cloudwatchLog)
17+
elasticSearchDomains: [awsElasticSearchDomain] @hasInverse(field: cloudwatchLogs)
18+
rdsDbInstance: [awsRdsDbInstance] @hasInverse(field: cloudwatchLogs)
19+
managedAirflows: [awsManagedAirflow] @hasInverse(field: cloudwatchLogs)
1720
}
1821

1922
type awsMetricFilter
Lines changed: 104 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,104 @@
1-
// TODO Add Optional IAM saml provider
1+
import { ServiceConnection } from '@cloudgraph/sdk'
2+
import { isEmpty } from 'lodash'
3+
import services from '../../enums/services'
4+
import { RawAwsCognitoIdentityPool } from './data'
5+
import { RawAwsIamRole } from '../iamRole/data'
6+
import { globalRegionName } from '../../enums/regions'
7+
8+
/**
9+
* Cognito Identity Pool
10+
*/
11+
12+
export default ({
13+
service: identityPool,
14+
data,
15+
region,
16+
}: {
17+
data: { name: string; data: { [property: string]: any[] } }[]
18+
service: RawAwsCognitoIdentityPool
19+
region: string
20+
}): { [key: string]: ServiceConnection[] } => {
21+
const connections: ServiceConnection[] = []
22+
23+
const {
24+
IdentityPoolId: id,
25+
identityPoolRoles,
26+
SamlProviderARNs = [],
27+
OpenIdConnectProviderARNs = [],
28+
} = identityPool
29+
30+
/**
31+
* Find related IAM Roles
32+
*/
33+
const roles: { name: string; data: { [property: string]: any[] } } =
34+
data.find(({ name }) => name === services.iamRole)
35+
36+
const iamRoleArns = Object.values(identityPoolRoles?.Roles || {})
37+
38+
if (roles?.data?.[globalRegionName]) {
39+
const dataAtRegion: RawAwsIamRole[] = roles.data[globalRegionName].filter(role =>
40+
iamRoleArns.includes(role.Arn)
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+
/**
57+
* Find iamSamlProvider
58+
* related to this cognito identity pool
59+
*/
60+
const iamSamlProviders = data.find(({ name }) => name === services.iamSamlProvider)
61+
if (iamSamlProviders?.data?.[region]) {
62+
const dataInRegion = iamSamlProviders.data[region].filter(provider =>
63+
SamlProviderARNs.includes(provider.arn)
64+
)
65+
66+
if (!isEmpty(dataInRegion)) {
67+
for (const provider of dataInRegion) {
68+
connections.push({
69+
id: provider.KeyId,
70+
resourceType: services.iamSamlProvider,
71+
relation: 'child',
72+
field: 'iamSamlProviders',
73+
})
74+
}
75+
}
76+
}
77+
78+
/**
79+
* Find iamOpenIdConnectProvider
80+
* related to this cognito identity pool
81+
*/
82+
const iamOpenIdConnectProviders = data.find(({ name }) => name === services.iamOpenIdConnectProvider)
83+
if (iamOpenIdConnectProviders?.data?.[region]) {
84+
const dataInRegion = iamOpenIdConnectProviders.data[region].filter(provider =>
85+
OpenIdConnectProviderARNs.includes(provider.arn)
86+
)
87+
88+
if (!isEmpty(dataInRegion)) {
89+
for (const provider of dataInRegion) {
90+
connections.push({
91+
id: provider.KeyId,
92+
resourceType: services.iamOpenIdConnectProvider,
93+
relation: 'child',
94+
field: 'iamOpenIdConnectProviders',
95+
})
96+
}
97+
}
98+
}
99+
100+
const identityPoolResult = {
101+
[id]: connections,
102+
}
103+
return identityPoolResult
104+
}

src/services/cognitoIdentityPool/data.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import COGID, {
22
IdentityPool,
33
IdentityPoolShortDescription,
4+
GetIdentityPoolRolesResponse,
45
} from 'aws-sdk/clients/cognitoidentity'
56
import { Config } from 'aws-sdk/lib/config'
67

@@ -25,6 +26,7 @@ const MAX_RESULTS = 60
2526

2627
export interface RawAwsCognitoIdentityPool
2728
extends Omit<IdentityPool, 'IdentityPoolTags'> {
29+
identityPoolRoles: GetIdentityPoolRolesResponse
2830
region: string
2931
Tags: TagMap
3032
}
@@ -91,6 +93,27 @@ const describeIdentityPool = async ({
9193
return null
9294
}
9395

96+
const getIdentityPoolRoles = async ({
97+
cogId,
98+
IdentityPoolId,
99+
}: {
100+
cogId: COGID
101+
IdentityPoolId: string
102+
}): Promise<GetIdentityPoolRolesResponse> => {
103+
try {
104+
return await cogId
105+
.getIdentityPoolRoles({ IdentityPoolId })
106+
.promise()
107+
108+
} catch (err) {
109+
errorLog.generateAwsErrorLog({
110+
functionName: 'cognitoIdentityPool:getIdentityPoolRoles',
111+
err,
112+
})
113+
}
114+
return null
115+
}
116+
94117
const listIdentityPoolData = async ({
95118
cogId,
96119
region,
@@ -106,8 +129,13 @@ const listIdentityPoolData = async ({
106129
cogId,
107130
IdentityPoolId: identityPoolId.IdentityPoolId,
108131
})
132+
const identityPoolRoles = await getIdentityPoolRoles({
133+
cogId,
134+
IdentityPoolId: identityPoolId.IdentityPoolId,
135+
})
109136
identityPoolData.push({
110137
...identityPool,
138+
identityPoolRoles,
111139
region,
112140
})
113141
}

src/services/cognitoIdentityPool/format.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
import { IdentityProviders } from 'aws-sdk/clients/cognitoidentity';
2-
import cuid from 'cuid';
1+
import { IdentityProviders } from 'aws-sdk/clients/cognitoidentity'
2+
import cuid from 'cuid'
33
import t from '../../properties/translations'
4-
5-
import { AwsCognitoIdentityPool, AwsSupportedLoginProvider } from '../../types/generated';
6-
import { formatTagsFromMap } from '../../utils/format';
7-
import { RawAwsCognitoIdentityPool } from './data';
4+
import { AwsCognitoIdentityPool, AwsSupportedLoginProvider } from '../../types/generated'
5+
import { formatTagsFromMap } from '../../utils/format'
6+
import { RawAwsCognitoIdentityPool } from './data'
7+
import {
8+
cognitoIdentityPoolArn,
9+
} from '../../utils/generateArns'
810

911
/**
1012
* Cognito Identity Pool
@@ -53,9 +55,12 @@ export default ({
5355
serverSideTokenCheck: serverSideTokenCheck? t.yes : t.no,
5456
})) || []
5557

58+
const arn = cognitoIdentityPoolArn({ region, account, identityPoolId })
59+
5660
const identityPool = {
5761
id: identityPoolId,
5862
accountId: account,
63+
arn,
5964
identityPoolName,
6065
allowUnauthenticatedIdentities: allowUnauthenticatedIdentities? t.yes : t.no,
6166
allowClassicFlow: allowClassicFlow? t.yes : t.no,

0 commit comments

Comments
 (0)