Skip to content

Commit 6be83d5

Browse files
authored
Merge pull request #15 from cloudgraphdev/fix/CG-1065
fix:(elasticBeanstalkEnv): add connection to iamRole
2 parents 6f63b0a + 7690d02 commit 6be83d5

File tree

5 files changed

+30
-4
lines changed

5 files changed

+30
-4
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ CloudGraph AWS Provider will ask you what regions you would like to crawl and wi
107107
| elastiCacheCluster | securityGroup, subnet, vpc |
108108
| elastiCacheReplicationGroup | kms |
109109
| elasticBeanstalkApp | elasticBeanstalkEnv, iamRole |
110-
| elasticBeanstalkEnv | ec2, elasticBeanstalkApp |
110+
| elasticBeanstalkEnv | ec2, elasticBeanstalkApp, iamRole |
111111
| elasticSearchDomain | kms, securityGroup, subnet, vpc |
112112
| elb | cloudfront, ecsService, securityGroup, subnet, vpc |
113113
| emrCluster | kms, subnet |
@@ -124,7 +124,7 @@ CloudGraph AWS Provider will ask you what regions you would like to crawl and wi
124124
| iamServerCertificate | |
125125
| iamUser | iamGroup |
126126
| iamPolicy | iamRole, iamGroup |
127-
| iamRole | appSync, asg, cloudformationStackSet, codebuild, configurationRecorder, ec2, iamInstanceProfile, iamPolicy, eksCluster, ecsService, flowLog, glueJob, managedAirflow, s3, sageMakerNotebookInstance, systemsManagerInstance, guardDutyDetector, lambda, kinesisFirehose, rdsCluster, elasticBeanstalkApp |
127+
| iamRole | appSync, asg, cloudformationStackSet, codebuild, configurationRecorder, ec2, iamInstanceProfile, iamPolicy, eksCluster, ecsService, flowLog, glueJob, managedAirflow, s3, sageMakerNotebookInstance, systemsManagerInstance, guardDutyDetector, lambda, kinesisFirehose, rdsCluster, elasticBeanstalkApp, elasticBeanstalkEnv |
128128
| iamGroup | iamUser, iamPolicy |
129129
| igw | vpc |
130130
| iot | |

src/services/elasticBeanstalkEnvironment/schema.graphql

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ type awsElasticBeanstalkEnv implements awsBaseService @key(fields: "arn") {
1010
solutionStackName: String @search(by: [hash, regexp])
1111
tier: String @search(by: [hash])
1212
versionLabel: String @search(by: [hash, regexp])
13+
iamRole: [awsIamRole] @hasInverse(field: elasticBeanstalkEnvs)
1314
tags: [awsRawTag]
1415
elasticBeanstalkApps: [awsElasticBeanstalkApp] @hasInverse(field: elasticBeanstalkEnvs)
1516
ec2Instances: [awsEc2] @hasInverse(field: elasticBeanstalkEnv)
@@ -27,5 +28,3 @@ type awsElasticBeanstalkEnvResource {
2728
name: String @search(by: [hash, regexp])
2829
value: [String] @search(by: [hash, regexp])
2930
}
30-
31-
# TODO: add iam role based on OperationsRole field

src/services/iamRole/connections.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { RawAwsGuardDutyDetector } from '../guardDutyDetector/data'
1616
import { RawAwsSageMakerNotebookInstance } from '../sageMakerNotebookInstance/data'
1717
import { RawAwsSystemsManagerInstance } from '../systemsManagerInstance/data'
1818
import { RawAwsElasticBeanstalkApp } from '../elasticBeanstalkApplication/data'
19+
import { RawAwsElasticBeanstalkEnv } from '../elasticBeanstalkEnvironment/data'
1920

2021
/**
2122
* IAM Role
@@ -254,6 +255,29 @@ export default ({
254255
}
255256
}
256257

258+
/**
259+
* Find any elasticBeanstalkEnv related data
260+
*/
261+
const elasticBEnvs = data.find(
262+
({ name }) => name === services.elasticBeanstalkEnv
263+
)
264+
if (elasticBEnvs?.data?.[region]) {
265+
const dataAtRegion: RawAwsElasticBeanstalkEnv[] = elasticBEnvs.data[
266+
region
267+
].filter(
268+
({ OperationsRole }: RawAwsElasticBeanstalkEnv) =>
269+
OperationsRole === role.Arn
270+
)
271+
for (const elasticBEnv of dataAtRegion) {
272+
connections.push({
273+
id: elasticBEnv.EnvironmentId,
274+
resourceType: services.elasticBeanstalkEnv,
275+
relation: 'child',
276+
field: 'elasticBeanstalkEnvs',
277+
})
278+
}
279+
}
280+
257281
return {
258282
[id]: connections,
259283
}

src/services/iamRole/schema.graphql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ type awsIamRole implements awsBaseService @key(fields: "id") {
1313
ecsServices: [awsEcsService] @hasInverse(field: iamRoles)
1414
eksClusters: [awsEksCluster] @hasInverse(field: iamRoles)
1515
elasticBeanstalkApps: [awsElasticBeanstalkApp] @hasInverse(field: iamRole)
16+
elasticBeanstalkEnvs: [awsElasticBeanstalkEnv] @hasInverse(field: iamRole)
1617
flowLogs: [awsFlowLog] @hasInverse(field: iamRole)
1718
glueJobs: [awsGlueJob] @hasInverse(field: iamRole)
1819
guardDutyDetectors: [awsGuardDutyDetector] @hasInverse(field: iamRole)

src/types/generated.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2504,6 +2504,7 @@ export type AwsElasticBeanstalkEnv = AwsBaseService & {
25042504
ec2Instances?: Maybe<Array<Maybe<AwsEc2>>>;
25052505
elasticBeanstalkApps?: Maybe<Array<Maybe<AwsElasticBeanstalkApp>>>;
25062506
endpointUrl?: Maybe<Scalars['String']>;
2507+
iamRole?: Maybe<Array<Maybe<AwsIamRole>>>;
25072508
name?: Maybe<Scalars['String']>;
25082509
platformArn?: Maybe<Scalars['String']>;
25092510
resources?: Maybe<Array<Maybe<AwsElasticBeanstalkEnvResource>>>;
@@ -3065,6 +3066,7 @@ export type AwsIamRole = AwsBaseService & {
30653066
ecsServices?: Maybe<Array<Maybe<AwsEcsService>>>;
30663067
eksClusters?: Maybe<Array<Maybe<AwsEksCluster>>>;
30673068
elasticBeanstalkApps?: Maybe<Array<Maybe<AwsElasticBeanstalkApp>>>;
3069+
elasticBeanstalkEnvs?: Maybe<Array<Maybe<AwsElasticBeanstalkEnv>>>;
30683070
flowLogs?: Maybe<Array<Maybe<AwsFlowLog>>>;
30693071
glueJobs?: Maybe<Array<Maybe<AwsGlueJob>>>;
30703072
guardDutyDetectors?: Maybe<Array<Maybe<AwsGuardDutyDetector>>>;

0 commit comments

Comments
 (0)