Skip to content

Commit a58ecda

Browse files
authored
Merge pull request #45 from cloudgraphdev/fix/CG-1079
fix(arn): Added ARN to some existing services
2 parents 6d98383 + 39f43b5 commit a58ecda

3 files changed

Lines changed: 58 additions & 26 deletions

File tree

src/services/flowLogs/format.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { AwsFlowLog } from '../../types/generated'
22
import { formatTagsFromMap } from '../../utils/format'
3+
import { flowLogsArn } from '../../utils/generateArns'
34
import { RawFlowLog } from './data'
45

56
/**
@@ -37,6 +38,11 @@ export default ({
3738

3839
const flowLog = {
3940
id,
41+
arn: flowLogsArn({
42+
region,
43+
account,
44+
flowLogId: id,
45+
}),
4046
region,
4147
accountId: account,
4248
deliverLogsErrorMessage,

src/services/guardDutyDetector/format.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import cuid from 'cuid'
22
import { formatTagsFromMap } from '../../utils/format'
33
import { AwsGuardDutyDetector } from '../../types/generated'
44
import { RawAwsGuardDutyDetector } from './data'
5+
import { guardDutyArn } from '../../utils/generateArns'
56

67
/**
78
* GuardDutyDetector
@@ -25,21 +26,21 @@ export default ({
2526
UpdatedAt: updatedAt,
2627
DataSources: dataSources,
2728
members = [],
28-
Tags
29+
Tags,
2930
} = rawData
3031

3132
const formattedDataSources = {
3233
cloudTrail: {
33-
status: dataSources?.CloudTrail?.Status
34+
status: dataSources?.CloudTrail?.Status,
3435
},
3536
dnsLogs: {
36-
status: dataSources?.DNSLogs?.Status
37+
status: dataSources?.DNSLogs?.Status,
3738
},
3839
flowLogs: {
39-
status: dataSources?.FlowLogs?.Status
40+
status: dataSources?.FlowLogs?.Status,
4041
},
4142
s3Logs: {
42-
status: dataSources?.S3Logs?.Status
43+
status: dataSources?.S3Logs?.Status,
4344
},
4445
// kubernetes: { TODO: k8s logs support, maybe need to update aws sdk?
4546
// auditLogs: {
@@ -56,11 +57,12 @@ export default ({
5657
email: member?.Email,
5758
relationshipStatus: member?.RelationshipStatus,
5859
invitedAt: new Date(member?.InvitedAt)?.toISOString(),
59-
updatedAt: new Date(member?.UpdatedAt)?.toISOString()
60+
updatedAt: new Date(member?.UpdatedAt)?.toISOString(),
6061
}))
6162

6263
return {
6364
id,
65+
arn: guardDutyArn({ region, account, detectorId: id }),
6466
region,
6567
accountId: account,
6668
createdAt: new Date(createdAt)?.toISOString(),
@@ -70,6 +72,6 @@ export default ({
7072
status,
7173
members: mappedMembers,
7274
dataSources: formattedDataSources,
73-
tags: formatTagsFromMap(Tags ?? {})
75+
tags: formatTagsFromMap(Tags ?? {}),
7476
}
7577
}

src/utils/generateArns.ts

Lines changed: 43 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export const apiGatewayMethodArn = ({ resourceArn, httpMethod }) =>
99
`${resourceArn}/methods/${httpMethod}`
1010
export const route53HostedZoneArn = ({ id }: { id: string }): string =>
1111
`arn:aws:route53:::hostedzone/${id}`
12+
1213
export const routeTableArn = ({
1314
region,
1415
account,
@@ -69,7 +70,7 @@ export const kmsArn = ({
6970
region: string
7071
account: string
7172
id: string
72-
}) : string => `arn:aws:kms:${region}:${account}:key/${id}`
73+
}): string => `arn:aws:kms:${region}:${account}:key/${id}`
7374

7475
export const ecsContainerArn = ({
7576
region,
@@ -105,7 +106,7 @@ export const ebsVolumeArn = ({
105106
region,
106107
account,
107108
id,
108-
} : {
109+
}: {
109110
region: string
110111
account: string
111112
id: string
@@ -115,7 +116,7 @@ export const ec2InstanceArn = ({
115116
region,
116117
account,
117118
id,
118-
} : {
119+
}: {
119120
region: string
120121
account: string
121122
id: string
@@ -125,7 +126,7 @@ export const eipAllocationArn = ({
125126
region,
126127
account,
127128
id,
128-
} : {
129+
}: {
129130
region: string
130131
account: string
131132
id: string
@@ -135,17 +136,18 @@ export const elbArn = ({
135136
region,
136137
account,
137138
name,
138-
} : {
139+
}: {
139140
region: string
140141
account: string
141142
name: string
142-
}): string => `arn:aws:elasticloadbalancing:${region}:${account}:loadbalancer/${name}`
143+
}): string =>
144+
`arn:aws:elasticloadbalancing:${region}:${account}:loadbalancer/${name}`
143145

144146
export const igwArn = ({
145147
region,
146148
account,
147149
id,
148-
} : {
150+
}: {
149151
region: string
150152
account: string
151153
id: string
@@ -155,7 +157,7 @@ export const networkInterfaceArn = ({
155157
region,
156158
account,
157159
id,
158-
} : {
160+
}: {
159161
region: string
160162
account: string
161163
id: string
@@ -165,7 +167,7 @@ export const securityGroupArn = ({
165167
region,
166168
account,
167169
id,
168-
} : {
170+
}: {
169171
region: string
170172
account: string
171173
id: string
@@ -175,7 +177,7 @@ export const vpcArn = ({
175177
region,
176178
account,
177179
id,
178-
} : {
180+
}: {
179181
region: string
180182
account: string
181183
id: string
@@ -185,7 +187,7 @@ export const clientVpnEndpointArn = ({
185187
region,
186188
account,
187189
id,
188-
} : {
190+
}: {
189191
region: string
190192
account: string
191193
id: string
@@ -195,7 +197,7 @@ export const vpnConnectionArn = ({
195197
region,
196198
account,
197199
id,
198-
} : {
200+
}: {
199201
region: string
200202
account: string
201203
id: string
@@ -205,11 +207,12 @@ export const transitGatewayAttachmentArn = ({
205207
region,
206208
account,
207209
id,
208-
} : {
210+
}: {
209211
region: string
210212
account: string
211213
id: string
212-
}): string => `arn:aws:ec2:${region}:${account}:transit-gateway-attachment/${id}`
214+
}): string =>
215+
`arn:aws:ec2:${region}:${account}:transit-gateway-attachment/${id}`
213216

214217
export const configurationRecorderArn = ({
215218
region,
@@ -224,7 +227,7 @@ export const configurationRecorderArn = ({
224227
export const athenaDataCatalogArn = ({
225228
region,
226229
account,
227-
name
230+
name,
228231
}: {
229232
region: string
230233
account: string
@@ -234,7 +237,7 @@ export const athenaDataCatalogArn = ({
234237
export const glueJobArn = ({
235238
region,
236239
account,
237-
name
240+
name,
238241
}: {
239242
region: string
240243
account: string
@@ -244,7 +247,7 @@ export const glueJobArn = ({
244247
export const ssmManagedInstanceArn = ({
245248
region,
246249
account,
247-
name
250+
name,
248251
}: {
249252
region: string
250253
account: string
@@ -254,7 +257,7 @@ export const ssmManagedInstanceArn = ({
254257
export const ssmDocumentArn = ({
255258
region,
256259
account,
257-
name
260+
name,
258261
}: {
259262
region: string
260263
account: string
@@ -269,4 +272,25 @@ export const cognitoIdentityPoolArn = ({
269272
region: string
270273
account: string
271274
identityPoolId: string
272-
}): string => `arn:aws:cognito-identity:${region}:${account}:identitypool/${identityPoolId}`
275+
}): string =>
276+
`arn:aws:cognito-identity:${region}:${account}:identitypool/${identityPoolId}`
277+
278+
export const flowLogsArn = ({
279+
region,
280+
account,
281+
flowLogId,
282+
}: {
283+
region: string
284+
account: string
285+
flowLogId: string
286+
}): string => `arn:aws:ec2:${region}:${account}:vpc-flow-log/${flowLogId}`
287+
288+
export const guardDutyArn = ({
289+
region,
290+
account,
291+
detectorId,
292+
}: {
293+
region: string
294+
account: string
295+
detectorId: string
296+
}): string => `arn:aws:guardduty:${region}:${account}:detector/${detectorId}`

0 commit comments

Comments
 (0)