@@ -17,7 +17,7 @@ import { join } from 'path'
17
17
export interface DdbExportStepFunctionProps {
18
18
name : string
19
19
table : dynamodb . ITable
20
- bucket : s3 . IBucket
20
+ firehoseBucket : s3 . IBucket
21
21
athenaResultBucket : s3 . IBucket
22
22
glueDb : glueAlpha . IDatabase
23
23
athenaWorkgroup : athena . CfnWorkGroup
@@ -33,7 +33,7 @@ export class DdbExportStepFunction extends Construct {
33
33
environment : {
34
34
REGION : Stack . of ( this ) . region ,
35
35
DYNAMO_DB_TABLE_ARN : props . table . tableArn ,
36
- S3_BUCKET_NAME : props . bucket . bucketName ,
36
+ S3_BUCKET_NAME : props . firehoseBucket . bucketName ,
37
37
} ,
38
38
} )
39
39
lambdaStartExport . addToRolePolicy (
@@ -45,13 +45,13 @@ export class DdbExportStepFunction extends Construct {
45
45
lambdaStartExport . addToRolePolicy (
46
46
new iam . PolicyStatement ( {
47
47
actions : [ 's3:PutObject' ] ,
48
- resources : [ `${ props . bucket . bucketArn } /*` ] ,
48
+ resources : [ `${ props . firehoseBucket . bucketArn } /*` ] ,
49
49
} )
50
50
)
51
51
lambdaStartExport . addToRolePolicy (
52
52
new iam . PolicyStatement ( {
53
53
actions : [ 'kms:Decrypt' ] ,
54
- resources : [ props . bucket . encryptionKey ! . keyArn ] ,
54
+ resources : [ props . firehoseBucket . encryptionKey ! . keyArn ] ,
55
55
} )
56
56
)
57
57
@@ -61,7 +61,7 @@ export class DdbExportStepFunction extends Construct {
61
61
environment : {
62
62
REGION : Stack . of ( this ) . region ,
63
63
DYNAMO_DB_TABLE_ARN : props . table . tableArn ,
64
- S3_BUCKET_NAME : props . bucket . bucketName ,
64
+ S3_BUCKET_NAME : props . firehoseBucket . bucketName ,
65
65
} ,
66
66
} )
67
67
lambdaCheckExportState . addToRolePolicy (
@@ -101,7 +101,7 @@ export class DdbExportStepFunction extends Construct {
101
101
102
102
const getSqlString = ( file : string ) : string => {
103
103
let createTableCommand = readFileSync ( join ( __dirname , `${ file } ` ) , 'utf-8' ) . toString ( )
104
- const s3Location = `s3://${ props . bucket . bucketName } /ddb-exports/AWSDynamoDB/ddb-export-id/data/`
104
+ const s3Location = `s3://${ props . firehoseBucket . bucketName } /ddb-exports/AWSDynamoDB/ddb-export-id/data/`
105
105
createTableCommand = createTableCommand . replace ( / s 3 L o c a t i o n / g, s3Location )
106
106
createTableCommand = createTableCommand . replace ( / t a b l e _ n a m e / g, athenaTableName )
107
107
return createTableCommand
@@ -137,18 +137,14 @@ export class DdbExportStepFunction extends Construct {
137
137
)
138
138
lambdaCreateAthenaTable . addToRolePolicy (
139
139
new iam . PolicyStatement ( {
140
- actions : [ 's3:*' ] ,
141
- resources : [ `*` ] ,
142
- // actions: ['s3:PutObject'],
143
- // resources: [`${props.bucket.bucketArn}/*`],
140
+ actions : [ 's3:PutObject' ] ,
141
+ resources : [ props . athenaResultBucket . bucketArn , `${ props . athenaResultBucket . bucketArn } /*` ] ,
144
142
} )
145
143
) ;
146
144
lambdaCreateAthenaTable . addToRolePolicy (
147
145
new iam . PolicyStatement ( {
148
- actions : [ 'kms:*' ] ,
149
- resources : [ '*' ] ,
150
- // actions: ['kms:Decrypt'],
151
- // resources: [props.bucket.encryptionKey!.keyArn],
146
+ actions : [ 'kms:Decrypt' , 'kms:GenerateDataKey' ] ,
147
+ resources : [ props . athenaResultBucket . encryptionKey ! . keyArn ] ,
152
148
} )
153
149
) ;
154
150
lambdaCreateAthenaTable . addToRolePolicy (
@@ -175,8 +171,8 @@ export class DdbExportStepFunction extends Construct {
175
171
'glue:UpdateTable'
176
172
] ,
177
173
resources : [
178
- `arn:aws:glue:${ Stack . of ( this ) . region } :${ Stack . of ( this ) . account } :catalog` , // remove?
179
- `arn:aws:glue:${ Stack . of ( this ) . region } :${ Stack . of ( this ) . account } :database/default` , // remove?
174
+ `arn:aws:glue:${ Stack . of ( this ) . region } :${ Stack . of ( this ) . account } :catalog` ,
175
+ // `arn:aws:glue:${Stack.of(this).region}:${Stack.of(this).account}:database/default`,
180
176
props . glueDb . databaseArn ,
181
177
`arn:aws:glue:${ Stack . of ( this ) . region } :${ Stack . of ( this ) . account } :table/${ props . glueDb . databaseName } /${ athenaTableName } ` ] ,
182
178
} )
@@ -225,7 +221,7 @@ export class DdbExportStepFunction extends Construct {
225
221
// https://aws.amazon.com/de/premiumsupport/knowledge-center/access-denied-athena/
226
222
sfn . addToRolePolicy (
227
223
new iam . PolicyStatement ( {
228
- actions : [ 's3:* ' ] ,
224
+ actions : [ 's3:PutObject ' ] ,
229
225
resources : [ props . athenaResultBucket . bucketArn , `${ props . athenaResultBucket . bucketArn } /*` ] ,
230
226
} )
231
227
)
@@ -235,31 +231,5 @@ export class DdbExportStepFunction extends Construct {
235
231
resources : [ props . athenaResultBucket . encryptionKey ! . keyArn ] ,
236
232
} )
237
233
)
238
- // sfn.addToRolePolicy(
239
- // new iam.PolicyStatement({
240
- // actions: [
241
- // 'glue:BatchCreatePartition',
242
- // 'glue:BatchDeletePartition',
243
- // 'glue:BatchDeleteTable',
244
- // 'glue:BatchGetPartition',
245
- // 'glue:CreateDatabase',
246
- // 'glue:CreatePartition',
247
- // 'glue:CreateTable',
248
- // 'glue:DeleteDatabase',
249
- // 'glue:DeletePartition',
250
- // 'glue:DeleteTable',
251
- // 'glue:GetDatabase',
252
- // 'glue:GetDatabases',
253
- // 'glue:GetPartition',
254
- // 'glue:GetPartitions',
255
- // 'glue:GetTable',
256
- // 'glue:GetTables',
257
- // 'glue:UpdateDatabase',
258
- // 'glue:UpdatePartition',
259
- // 'glue:UpdateTable'
260
- // ],
261
- // resources: [props.glueDb.databaseArn, `arn:aws:glue:${Stack.of(this).region}:${Stack.of(this).account}:table/${props.glueDb.databaseName}/${athenaTableName}`],
262
- // })
263
- // )
264
234
}
265
235
}
0 commit comments