Skip to content

Commit 30ad96c

Browse files
author
Marco Franceschi
committed
feat: Replaced cuid with unique ids for policies
1 parent 0da99a4 commit 30ad96c

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

src/utils/format.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import cuid from 'cuid'
21
import { parseString } from '@fast-csv/parse'
3-
import CloudGraph from '@cloudgraph/sdk'
2+
import CloudGraph, { generateUniqueId } from '@cloudgraph/sdk'
43
import isArray from 'lodash/isArray'
54
import toString from 'lodash/toString'
65
import { AwsRawTag, AwsIamJsonPolicy } from '../types/generated'
@@ -91,17 +90,17 @@ export const formatIamJsonPolicy = (json: string): AwsIamJsonPolicy => {
9190

9291
const formatPrincipal = principal => {
9392
if (!principal) return null
94-
return Object.entries(principal).map(([key, value]) => {
93+
return Object.entries(principal).map(([key, value]) => {
9594
const conVal = (isArray(value) ? value : [value]) || []
9695
return {
9796
key: key === '0' ? '' : key.toString(),
9897
value: conVal.map(val => toString(val)),
9998
}
100-
})
99+
})
101100
}
102101

103102
return {
104-
id: cuid(),
103+
id: generateUniqueId(json),
105104
version: object.Version,
106105
statement: statement.map(el => ({
107106
action: isArray(el.Action) ? el.Action : [toString(el.Action)],

0 commit comments

Comments
 (0)