Skip to content

Commit dde6694

Browse files
committed
fix(services): Added encryption rules data to s3 service
1 parent a118711 commit dde6694

3 files changed

Lines changed: 67 additions & 34 deletions

File tree

src/services/s3/format.ts

Lines changed: 48 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
Policy,
88
PolicyStatus,
99
PublicAccessBlockConfiguration,
10+
ServerSideEncryptionConfiguration,
1011
} from 'aws-sdk/clients/s3'
1112

1213
import { AwsS3 } from '../../types/generated'
@@ -138,10 +139,16 @@ export default ({
138139
corsAdditions.corsConfiguration = t.yes
139140
}
140141

141-
const encryptionAdditions = { encrypted: t.no }
142+
const encryptionAdditions = { encrypted: t.no, encryptionRules: [] }
142143

143144
if (!isEmpty(encryptionInfo)) {
145+
const { Rules } = encryptionInfo as ServerSideEncryptionConfiguration
144146
encryptionAdditions.encrypted = t.yes
147+
encryptionAdditions.encryptionRules = Rules.map(r => ({
148+
id: cuid(),
149+
sseAlgorithm: r.ApplyServerSideEncryptionByDefault?.SSEAlgorithm,
150+
kmsMasterKeyID: r.ApplyServerSideEncryptionByDefault?.KMSMasterKeyID,
151+
}))
145152
}
146153

147154
const replicationAdditions = { crossRegionReplication: t.disabled }
@@ -182,36 +189,42 @@ export default ({
182189
LambdaFunctionConfigurations: lambdaFunctionConfigurations = [],
183190
}: NotificationConfiguration = notificationConfiguration
184191
notificationConfigurationData = {
185-
topicConfigurations: topicConfigurations?.map(tc => ({
186-
id: tc.Id || cuid(),
187-
topicArn: tc.TopicArn,
188-
events: tc.Events || [],
189-
filterRules: tc.Filter?.Key?.FilterRules?.map(r => ({
190-
id: cuid(),
191-
name: r.Name,
192-
value: r.Value,
192+
topicConfigurations:
193+
topicConfigurations?.map(tc => ({
194+
id: tc.Id || cuid(),
195+
topicArn: tc.TopicArn,
196+
events: tc.Events || [],
197+
filterRules:
198+
tc.Filter?.Key?.FilterRules?.map(r => ({
199+
id: cuid(),
200+
name: r.Name,
201+
value: r.Value,
202+
})) || [],
193203
})) || [],
194-
})) || [],
195-
queueConfigurations: queueConfigurations?.map(qc => ({
196-
id: qc.Id || cuid(),
197-
queueArn: qc.QueueArn,
198-
events: qc.Events || [],
199-
filterRules: qc.Filter?.Key?.FilterRules?.map(r => ({
200-
id: cuid(),
201-
name: r.Name,
202-
value: r.Value,
204+
queueConfigurations:
205+
queueConfigurations?.map(qc => ({
206+
id: qc.Id || cuid(),
207+
queueArn: qc.QueueArn,
208+
events: qc.Events || [],
209+
filterRules:
210+
qc.Filter?.Key?.FilterRules?.map(r => ({
211+
id: cuid(),
212+
name: r.Name,
213+
value: r.Value,
214+
})) || [],
203215
})) || [],
204-
})) || [],
205-
lambdaFunctionConfigurations: lambdaFunctionConfigurations?.map(lc => ({
206-
id: lc.Id || cuid(),
207-
lambdaFunctionArn: lc.LambdaFunctionArn,
208-
events: lc.Events || [],
209-
filterRules: lc.Filter?.Key?.FilterRules?.map(r => ({
210-
id: cuid(),
211-
name: r.Name,
212-
value: r.Value,
216+
lambdaFunctionConfigurations:
217+
lambdaFunctionConfigurations?.map(lc => ({
218+
id: lc.Id || cuid(),
219+
lambdaFunctionArn: lc.LambdaFunctionArn,
220+
events: lc.Events || [],
221+
filterRules:
222+
lc.Filter?.Key?.FilterRules?.map(r => ({
223+
id: cuid(),
224+
name: r.Name,
225+
value: r.Value,
226+
})) || [],
213227
})) || [],
214-
})) || [],
215228
}
216229
}
217230

@@ -243,12 +256,13 @@ export default ({
243256
: `${total}`,
244257
transferAcceleration: accelerationStatus,
245258
notificationConfiguration: notificationConfigurationData,
246-
aclGrants: grants?.map(g => ({
247-
id: cuid(),
248-
granteeType: g.Grantee?.Type,
249-
granteeUri: g.Grantee?.URI,
250-
permission: g.Permission,
251-
})) || [],
259+
aclGrants:
260+
grants?.map(g => ({
261+
id: cuid(),
262+
granteeType: g.Grantee?.Type,
263+
granteeUri: g.Grantee?.URI,
264+
permission: g.Permission,
265+
})) || [],
252266
}
253267
return s3
254268
}

src/services/s3/schema.graphql

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,17 @@ type awsS3AclGrant
6565
permission: String @search(by: [hash])
6666
}
6767

68+
type awsS3ServerSideEncryptionConfiguration
69+
@generate(
70+
query: { get: false, query: true, aggregate: false }
71+
mutation: { add: false, delete: false }
72+
subscription: false
73+
) {
74+
id: String! @id
75+
sseAlgorithm: String @search(by: [hash])
76+
kmsMasterKeyID: String @search(by: [hash])
77+
}
78+
6879
type awsS3 implements awsBaseService @key(fields: "arn") {
6980
access: String @search(by: [hash, regexp])
7081
bucketOwnerName: String @search(by: [hash, regexp])
@@ -74,6 +85,7 @@ type awsS3 implements awsBaseService @key(fields: "arn") {
7485
transferAcceleration: String @search(by: [hash, regexp])
7586
corsConfiguration: String @search(by: [hash, regexp])
7687
encrypted: String @search(by: [hash, regexp])
88+
encryptionRules: [awsS3ServerSideEncryptionConfiguration]
7789
lifecycle: String @search(by: [hash, regexp])
7890
logging: String @search(by: [hash, regexp])
7991
blockPublicAcls: String @search(by: [hash, regexp])

src/types/generated.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3836,6 +3836,7 @@ export type AwsS3 = AwsBaseService & {
38363836
crossRegionReplication?: Maybe<Scalars['String']>;
38373837
ecsCluster?: Maybe<Array<Maybe<AwsEcsCluster>>>;
38383838
encrypted?: Maybe<Scalars['String']>;
3839+
encryptionRules?: Maybe<Array<Maybe<AwsS3ServerSideEncryptionConfiguration>>>;
38393840
iamRole?: Maybe<Array<Maybe<AwsIamRole>>>;
38403841
ignorePublicAcls?: Maybe<Scalars['String']>;
38413842
kinesisFirehose?: Maybe<Array<Maybe<AwsKinesisFirehose>>>;
@@ -3892,6 +3893,12 @@ export type AwsS3QueueConfiguration = AwsS3ConfigurationBase & {
38923893
queueArn?: Maybe<Scalars['String']>;
38933894
};
38943895

3896+
export type AwsS3ServerSideEncryptionConfiguration = {
3897+
id: Scalars['String'];
3898+
kmsMasterKeyID?: Maybe<Scalars['String']>;
3899+
sseAlgorithm?: Maybe<Scalars['String']>;
3900+
};
3901+
38953902
export type AwsS3TopicConfiguration = AwsS3ConfigurationBase & {
38963903
topicArn?: Maybe<Scalars['String']>;
38973904
};

0 commit comments

Comments
 (0)