Skip to content

Commit dbb9405

Browse files
author
Marco Franceschi
committed
fix: Added missing connections to managedAirflow
1 parent f7f443b commit dbb9405

File tree

7 files changed

+109
-35
lines changed

7 files changed

+109
-35
lines changed

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/cloudwatchLogs/schema.graphql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ type awsCloudwatchLog @key(fields: "arn") {
1515
cloudtrail: [awsCloudtrail] @hasInverse(field: cloudwatchLog)
1616
ecsCluster: [awsEcsCluster] @hasInverse(field: cloudwatchLog)
1717
rdsDbInstance: [awsRdsDbInstance] @hasInverse(field: cloudwatchLogs)
18+
managedAirflows: [awsManagedAirflow] @hasInverse(field: cloudwatchLogs)
1819
}
1920

2021
type awsMetricFilter

src/services/iamRole/schema.graphql

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@ type awsIamRole implements awsBaseService @key(fields: "id") {
2020
iamAttachedPolicies: [awsIamPolicy] @hasInverse(field: iamRoles)
2121
iamInstanceProfiles: [awsIamInstanceProfile] @hasInverse(field: iamRole)
2222
managedAirflows: [awsManagedAirflow] @hasInverse(field: iamRoles)
23-
sageMakerNotebookInstances: [awsSageMakerNotebookInstance] @hasInverse(field: iamRole)
24-
systemsManagerInstances: [awsSystemsManagerInstance] @hasInverse(field: iamRole)
23+
sageMakerNotebookInstances: [awsSageMakerNotebookInstance]
24+
@hasInverse(field: iamRole)
25+
systemsManagerInstances: [awsSystemsManagerInstance]
26+
@hasInverse(field: iamRole)
2527
s3: [awsS3] @hasInverse(field: iamRole)
2628
dynamodb: [awsDynamoDbTable] @hasInverse(field: iamRoles)
2729
ec2Instances: [awsEc2] @hasInverse(field: iamRole)

src/services/kms/schema.graphql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,5 @@ type awsKms implements awsBaseService @key(fields: "id") {
4949
cognitoUserPools: [awsCognitoUserPool] @hasInverse(field: kms)
5050
rdsCluster: [awsRdsCluster] @hasInverse(field: kms)
5151
rdsDbInstance: [awsRdsDbInstance] @hasInverse(field: kms)
52+
managedAirflows: [awsManagedAirflow] @hasInverse(field: kms)
5253
}

src/services/managedAirflow/connections.ts

Lines changed: 96 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import services from '../../enums/services'
44
import { RawAwsManagedAirflow } from '../managedAirflow/data'
55
import { RawAwsS3 } from '../s3/data'
66
import { AwsSecurityGroup } from '../securityGroup/data'
7+
import { RawAwsLogGroup } from '../cloudwatchLogs/data'
8+
import { AwsKms } from '../kms/data'
79
import { s3BucketArn } from '../../utils/generateArns'
810

911
export default ({
@@ -17,49 +19,110 @@ export default ({
1719
}): {
1820
[property: string]: ServiceConnection[]
1921
} => {
20-
const { Arn, SourceBucketArn, NetworkConfiguration: { SecurityGroupIds = [] } = {} } = airflow
22+
const {
23+
Arn: id,
24+
SourceBucketArn,
25+
NetworkConfiguration: { SecurityGroupIds = [] } = {},
26+
LoggingConfiguration,
27+
KmsKey,
28+
} = airflow
2129
const connections: ServiceConnection[] = []
2230

2331
/**
2432
* Find any S3 related data
2533
*/
26-
const buckets = data.find(({ name }) => name === services.s3)
27-
if (buckets?.data?.[region]) {
28-
const dataAtRegion: RawAwsS3[] = buckets.data[region].filter(
29-
({ Name: name }: RawAwsS3) =>
30-
s3BucketArn({ name }) === SourceBucketArn
31-
)
32-
for (const bucket of dataAtRegion) {
33-
connections.push({
34-
id: bucket.Id,
35-
resourceType: services.s3,
36-
relation: 'child',
37-
field: 's3',
38-
})
39-
}
40-
}
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) => s3BucketArn({ name }) === SourceBucketArn
38+
)
39+
for (const bucket of dataAtRegion) {
40+
connections.push({
41+
id: bucket.Id,
42+
resourceType: services.s3,
43+
relation: 'child',
44+
field: 's3',
45+
})
46+
}
47+
}
4148

42-
/**
49+
/**
4350
* Find any securityGroups related data
4451
*/
45-
const securityGroups = data.find(({ name }) => name === services.sg)
46-
if (securityGroups?.data?.[region]) {
47-
const dataAtRegion: AwsSecurityGroup[] = securityGroups.data[region].filter(
48-
({ GroupId }: AwsSecurityGroup) =>
49-
SecurityGroupIds.includes(GroupId)
50-
)
51-
for (const securityGroup of dataAtRegion) {
52-
connections.push({
53-
id: securityGroup.GroupId,
54-
resourceType: services.sg,
55-
relation: 'child',
56-
field: 'securityGroups',
57-
})
52+
const securityGroups = data.find(({ name }) => name === services.sg)
53+
if (securityGroups?.data?.[region]) {
54+
const dataAtRegion: AwsSecurityGroup[] = securityGroups.data[region].filter(
55+
({ GroupId }: AwsSecurityGroup) => SecurityGroupIds.includes(GroupId)
56+
)
57+
for (const securityGroup of dataAtRegion) {
58+
connections.push({
59+
id: securityGroup.GroupId,
60+
resourceType: services.sg,
61+
relation: 'child',
62+
field: 'securityGroups',
63+
})
64+
}
65+
}
66+
67+
/**
68+
* Find any cloudwatch log group related data
69+
*/
70+
const cloudwatchLogs = data.find(
71+
({ name }) => name === services.cloudwatchLog
72+
)
73+
if (cloudwatchLogs?.data?.[region]) {
74+
const dataAtRegion: RawAwsLogGroup[] = cloudwatchLogs.data[region].filter(
75+
({ logGroupName }: RawAwsLogGroup) => {
76+
return (
77+
LoggingConfiguration?.TaskLogs?.CloudWatchLogGroupArn?.includes(
78+
logGroupName
79+
) ||
80+
LoggingConfiguration?.SchedulerLogs?.CloudWatchLogGroupArn?.includes(
81+
logGroupName
82+
) ||
83+
LoggingConfiguration?.WorkerLogs?.CloudWatchLogGroupArn?.includes(
84+
logGroupName
85+
) ||
86+
LoggingConfiguration?.WebserverLogs?.CloudWatchLogGroupArn?.includes(
87+
logGroupName
88+
) ||
89+
LoggingConfiguration?.DagProcessingLogs?.CloudWatchLogGroupArn?.includes(
90+
logGroupName
91+
)
92+
)
5893
}
94+
)
95+
96+
for (const logGroup of dataAtRegion) {
97+
connections.push({
98+
id: logGroup.logGroupName,
99+
resourceType: services.cloudwatchLog,
100+
relation: 'child',
101+
field: 'cloudwatchLogs',
102+
})
103+
}
104+
}
105+
106+
/**
107+
* Find any kms related data
108+
*/
109+
const kms = data.find(({ name }) => name === services.kms)
110+
if (kms?.data?.[region]) {
111+
const dataAtRegion: AwsKms[] = kms.data[region].filter(
112+
({ Arn }: AwsKms) => Arn === KmsKey
113+
)
114+
115+
for (const kmsKey of dataAtRegion) {
116+
connections.push({
117+
id: kmsKey.KeyId,
118+
resourceType: services.kms,
119+
relation: 'child',
120+
field: 'kms',
121+
})
59122
}
123+
}
60124

61-
const natResult = {
62-
[Arn]: connections,
125+
return {
126+
[id]: connections,
63127
}
64-
return natResult
65128
}

src/services/managedAirflow/schema.graphql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ type awsManagedAirflow implements awsBaseService @key(fields: "arn") {
2626
subnets: [awsSubnet] @hasInverse(field: managedAirflows)
2727
securityGroups: [awsSecurityGroup] @hasInverse(field: managedAirflows)
2828
s3: [awsS3] @hasInverse(field: managedAirflows)
29+
kms: [awsKms] @hasInverse(field: managedAirflows)
30+
cloudwatchLogs: [awsCloudwatchLog] @hasInverse(field: managedAirflows)
2931
}
3032

3133
type awsManagedAirflowNetworkConfig {

src/types/generated.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -922,6 +922,7 @@ export type AwsCloudwatchLog = {
922922
id: Scalars['String'];
923923
kms?: Maybe<Array<Maybe<AwsKms>>>;
924924
kmsKeyId?: Maybe<Scalars['String']>;
925+
managedAirflows?: Maybe<Array<Maybe<AwsManagedAirflow>>>;
925926
metricFilterCount?: Maybe<Scalars['Int']>;
926927
metricFilters?: Maybe<Array<Maybe<AwsMetricFilter>>>;
927928
rdsDbInstance?: Maybe<Array<Maybe<AwsRdsDbInstance>>>;
@@ -3218,6 +3219,7 @@ export type AwsKms = AwsBaseService & {
32183219
keyRotationEnabled?: Maybe<Scalars['Boolean']>;
32193220
keyState?: Maybe<Scalars['String']>;
32203221
lambda?: Maybe<Array<Maybe<AwsLambda>>>;
3222+
managedAirflows?: Maybe<Array<Maybe<AwsManagedAirflow>>>;
32213223
origin?: Maybe<Scalars['String']>;
32223224
policy?: Maybe<AwsIamJsonPolicy>;
32233225
rdsCluster?: Maybe<Array<Maybe<AwsRdsCluster>>>;
@@ -3324,11 +3326,13 @@ export type AwsLcBlockDeviceMapping = {
33243326
export type AwsManagedAirflow = AwsBaseService & {
33253327
airflowConfigurationOptions?: Maybe<Array<Maybe<AwsRawTag>>>;
33263328
airflowVersion?: Maybe<Scalars['String']>;
3329+
cloudwatchLogs?: Maybe<Array<Maybe<AwsCloudwatchLog>>>;
33273330
createdAt?: Maybe<Scalars['DateTime']>;
33283331
dagS3Path?: Maybe<Scalars['String']>;
33293332
environmentClass?: Maybe<Scalars['String']>;
33303333
executionRoleArn?: Maybe<Scalars['String']>;
33313334
iamRoles?: Maybe<Array<Maybe<AwsIamRole>>>;
3335+
kms?: Maybe<Array<Maybe<AwsKms>>>;
33323336
kmsKey?: Maybe<Scalars['String']>;
33333337
lastUpdate?: Maybe<AwsManagedAirflowLastUpdate>;
33343338
loggingConfiguration?: Maybe<AwsManagedAirflowLoggingConfig>;

0 commit comments

Comments
 (0)