Skip to content

Commit 39f43b5

Browse files
author
Marco Franceschi
committed
fix: Generated ARN for guardDuty
1 parent 1d372a9 commit 39f43b5

2 files changed

Lines changed: 19 additions & 7 deletions

File tree

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: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,3 +284,13 @@ export const flowLogsArn = ({
284284
account: string
285285
flowLogId: string
286286
}): 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)