Skip to content

Commit d576b40

Browse files
committed
feat(aws): support missing iam services
1 parent abedccf commit d576b40

8 files changed

Lines changed: 67 additions & 1 deletion

File tree

src/services/iamGroup/format.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export default ({
1818
Arn: arn = '',
1919
Path: path = '',
2020
Policies: inlinePolicies = [],
21+
ManagedPolicies: managedPolicies = [],
2122
} = rawData
2223

2324
const record = {
@@ -27,6 +28,10 @@ export default ({
2728
path,
2829
name,
2930
inlinePolicies,
31+
managedPolicies: managedPolicies.map(({ PolicyArn, PolicyName }) => ({
32+
policyArn: PolicyArn,
33+
policyName: PolicyName,
34+
})),
3035
}
3136
return record
3237
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
1+
type awsIamGroupAttachedPolicy
2+
@generate(
3+
query: { get: false, query: false, aggregate: false }
4+
mutation: { add: false, delete: false }
5+
subscription: false
6+
) {
7+
policyArn: String! @id @search(by: [hash, regexp])
8+
policyName: String @search(by: [hash, regexp])
9+
}
10+
111
type awsIamGroup implements awsBaseService @key(fields: "id") {
212
path: String @search(by: [hash, regexp])
313
name: String @search(by: [hash, regexp])
414
inlinePolicies: [String]
15+
managedPolicies: [awsIamGroupAttachedPolicy]
516
iamAttachedPolicies: [awsIamPolicy] @hasInverse(field: iamGroups)
617
iamUsers: [awsIamUser] @hasInverse(field: iamGroups)
718
}

src/services/iamRole/format.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export default ({
2626
AssumeRolePolicyDocument: assumeRolePolicy = '',
2727
MaxSessionDuration: maxSessionDuration = 0,
2828
InlinePolicies: inlinePolicies = [],
29+
ManagedPolicies: managedPolicies = [],
2930
Tags: tags = {},
3031
} = rawData
3132

@@ -55,6 +56,10 @@ export default ({
5556
document: formatIamJsonPolicy(inlinePolicyDocument),
5657
})
5758
) ?? [],
59+
managedPolicies: managedPolicies.map(({ PolicyArn, PolicyName }) => ({
60+
policyArn: PolicyArn,
61+
policyName: PolicyName,
62+
})),
5863
tags: roleTags,
5964
}
6065
return role

src/services/iamRole/schema.graphql

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
type awsIamRoleAttachedPolicy
2+
@generate(
3+
query: { get: false, query: false, aggregate: false }
4+
mutation: { add: false, delete: false }
5+
subscription: false
6+
) {
7+
policyArn: String! @id @search(by: [hash, regexp])
8+
policyName: String @search(by: [hash, regexp])
9+
}
10+
111
type awsIamRoleInlinePolicy
212
@generate(
313
query: { get: false, query: true, aggregate: false }
@@ -20,6 +30,7 @@ type awsIamRole implements awsBaseService @key(fields: "id") {
2030
maxSessionDuration: Int @search
2131
tags: [awsRawTag]
2232
inlinePolicies: [awsIamRoleInlinePolicy]
33+
managedPolicies: [awsIamRoleAttachedPolicy]
2334
cloudFormationStack: [awsCloudFormationStack] @hasInverse(field: iamRole)
2435
codebuilds: [awsCodebuild] @hasInverse(field: iamRoles)
2536
configurationRecorder: [awsConfigurationRecorder] @hasInverse(field: iamRole)

src/services/iamUser/data.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ const groupsByUsername = async (
131131
if (!isEmpty(data)) {
132132
const { Groups = [] } = data
133133

134-
const userGroups = Groups.map(({ GroupId }) => GroupId)
134+
const userGroups = Groups.map(({ GroupName }) => GroupName)
135135

136136
resolve({ UserName, Groups: userGroups })
137137
}

src/services/iamUser/format.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export default ({
2727
VirtualMFADevices: virtualMfaDevices = [],
2828
Groups: groups = [],
2929
Policies: inlinePolicies = [],
30+
ManagedPolicies: managedPolicies = [],
3031
ReportData: {
3132
AccessKey1LastRotated: accessKey1LastRotated,
3233
AccessKey2LastRotated: accessKey2LastRotated,
@@ -130,6 +131,10 @@ export default ({
130131
mfaActive: mfaActive === 'true',
131132
groups,
132133
inlinePolicies,
134+
managedPolicies: managedPolicies.map(({ PolicyArn, PolicyName }) => ({
135+
policyArn: PolicyArn,
136+
policyName: PolicyName,
137+
})),
133138
tags: userTags,
134139
}
135140
return user

src/services/iamUser/schema.graphql

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ type awsIamUser implements awsOptionalService @key(fields: "id") {
1414
groups: [String]
1515
tags: [awsRawTag]
1616
inlinePolicies: [String]
17+
managedPolicies: [awsIamAttachedPolicy]
1718
iamAttachedPolicies: [awsIamPolicy] @hasInverse(field: iamUsers)
1819
iamGroups: [awsIamGroup] @hasInverse(field: iamUsers)
1920
}
@@ -42,3 +43,13 @@ type awsIamMfaDevice
4243
serialNumber: String! @id @search(by: [hash, regexp])
4344
enableDate: String @search(by: [hash, regexp])
4445
}
46+
47+
type awsIamAttachedPolicy
48+
@generate(
49+
query: { get: false, query: false, aggregate: false }
50+
mutation: { add: false, delete: false }
51+
subscription: false
52+
) {
53+
policyArn: String! @id @search(by: [hash, regexp])
54+
policyName: String @search(by: [hash, regexp])
55+
}

src/types/generated.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3175,14 +3175,25 @@ export type AwsIamAccessKey = {
31753175
status?: Maybe<Scalars['String']>;
31763176
};
31773177

3178+
export type AwsIamAttachedPolicy = {
3179+
policyArn: Scalars['String'];
3180+
policyName?: Maybe<Scalars['String']>;
3181+
};
3182+
31783183
export type AwsIamGroup = AwsBaseService & {
31793184
iamAttachedPolicies?: Maybe<Array<Maybe<AwsIamPolicy>>>;
31803185
iamUsers?: Maybe<Array<Maybe<AwsIamUser>>>;
31813186
inlinePolicies?: Maybe<Array<Maybe<Scalars['String']>>>;
3187+
managedPolicies?: Maybe<Array<Maybe<AwsIamGroupAttachedPolicy>>>;
31823188
name?: Maybe<Scalars['String']>;
31833189
path?: Maybe<Scalars['String']>;
31843190
};
31853191

3192+
export type AwsIamGroupAttachedPolicy = {
3193+
policyArn: Scalars['String'];
3194+
policyName?: Maybe<Scalars['String']>;
3195+
};
3196+
31863197
export type AwsIamInstanceProfile = AwsBaseService & {
31873198
createDate?: Maybe<Scalars['DateTime']>;
31883199
ec2Instances?: Maybe<Array<Maybe<AwsEc2>>>;
@@ -3299,6 +3310,7 @@ export type AwsIamRole = AwsBaseService & {
32993310
lambda?: Maybe<Array<Maybe<AwsLambda>>>;
33003311
lastUsedDate?: Maybe<Scalars['DateTime']>;
33013312
managedAirflows?: Maybe<Array<Maybe<AwsManagedAirflow>>>;
3313+
managedPolicies?: Maybe<Array<Maybe<AwsIamRoleAttachedPolicy>>>;
33023314
maxSessionDuration?: Maybe<Scalars['Int']>;
33033315
name?: Maybe<Scalars['String']>;
33043316
path?: Maybe<Scalars['String']>;
@@ -3311,6 +3323,11 @@ export type AwsIamRole = AwsBaseService & {
33113323
tags?: Maybe<Array<Maybe<AwsRawTag>>>;
33123324
};
33133325

3326+
export type AwsIamRoleAttachedPolicy = {
3327+
policyArn: Scalars['String'];
3328+
policyName?: Maybe<Scalars['String']>;
3329+
};
3330+
33143331
export type AwsIamRoleInlinePolicy = {
33153332
document?: Maybe<AwsIamJsonPolicy>;
33163333
id: Scalars['String'];
@@ -3339,6 +3356,7 @@ export type AwsIamUser = AwsOptionalService & {
33393356
iamAttachedPolicies?: Maybe<Array<Maybe<AwsIamPolicy>>>;
33403357
iamGroups?: Maybe<Array<Maybe<AwsIamGroup>>>;
33413358
inlinePolicies?: Maybe<Array<Maybe<Scalars['String']>>>;
3359+
managedPolicies?: Maybe<Array<Maybe<AwsIamAttachedPolicy>>>;
33423360
mfaActive?: Maybe<Scalars['Boolean']>;
33433361
mfaDevices?: Maybe<Array<Maybe<AwsIamMfaDevice>>>;
33443362
name?: Maybe<Scalars['String']>;

0 commit comments

Comments
 (0)