@@ -228,86 +228,4 @@ describe('S3EventSource', () => {
228
228
} ,
229
229
} ) ;
230
230
} ) ;
231
- test ( 'Cross account buckect access' , ( ) => {
232
- // GIVEN
233
- const app = new cdk . App ( ) ;
234
- const stack = new cdk . Stack ( app , 'stack' ) ;
235
- const fn = new TestFunction ( stack , 'Fn' ) ;
236
-
237
- let accountB = '1234567' ;
238
- //WHEN
239
- const foreignBucket =
240
- s3 . Bucket . fromBucketAttributes ( stack , 'ImportedBucket' , {
241
- bucketArn : 'arn:aws:s3:::some-bucket-not-in-this-account' ,
242
- // The account the bucket really lives in
243
- account : accountB ,
244
- } ) ;
245
-
246
- // This will generate the IAM bindings
247
- fn . addEventSource ( new sources . S3EventSource ( foreignBucket as s3 . Bucket ,
248
- { events : [ s3 . EventType . OBJECT_CREATED ] } ) ) ;
249
-
250
- // THEN
251
- Template . fromStack ( stack ) . hasResourceProperties ( 'AWS::Lambda::Permission' , {
252
- 'Principal' : 's3.amazonaws.com' ,
253
- 'SourceAccount' : '1234567' ,
254
- 'SourceArn' : 'arn:aws:s3:::some-bucket-not-in-this-account' ,
255
- } ) ;
256
- } ) ;
257
-
258
- test ( 'Test bucket account is referenced intrinsicly' , ( ) => {
259
- // GIVEN
260
- const stack = new cdk . Stack ( ) ;
261
- const fn = new TestFunction ( stack , 'Fn' ) ;
262
- const bucket = new s3 . Bucket ( stack , 'B' ) ;
263
-
264
- // WHEN
265
- fn . addEventSource ( new sources . S3EventSource ( bucket , {
266
- events : [ s3 . EventType . OBJECT_CREATED , s3 . EventType . OBJECT_REMOVED ] ,
267
- filters : [
268
- { prefix : 'prefix/' } ,
269
- { suffix : '.png' } ,
270
- ] ,
271
- } ) ) ;
272
-
273
- // THEN
274
- Template . fromStack ( stack ) . hasResourceProperties ( 'AWS::Lambda::Permission' , {
275
- 'Principal' : 's3.amazonaws.com' ,
276
- 'SourceAccount' : {
277
- 'Ref' : 'AWS::AccountId' ,
278
- } ,
279
- 'SourceArn' : {
280
- 'Fn::GetAtt' : [ 'B08E7C7AF' , 'Arn' ] ,
281
- } ,
282
- } ) ;
283
- } ) ;
284
-
285
- test ( 'Default to stack account if bucket account doesnt exist' , ( ) => {
286
- // GIVEN
287
- const app = new cdk . App ( ) ;
288
- const stack = new cdk . Stack ( app , 'stack' ) ;
289
- const fn = new TestFunction ( stack , 'Fn' ) ;
290
-
291
- let accountB = '' ;
292
- //WHEN
293
- const foreignBucket =
294
- s3 . Bucket . fromBucketAttributes ( stack , 'ImportedBucket' , {
295
- bucketArn : 'arn:aws:s3:::some-bucket-not-in-this-account' ,
296
- // The account the bucket really lives in
297
- account : accountB ,
298
- } ) ;
299
-
300
- // This will generate the IAM bindings
301
- fn . addEventSource ( new sources . S3EventSource ( foreignBucket as s3 . Bucket ,
302
- { events : [ s3 . EventType . OBJECT_CREATED ] } ) ) ;
303
-
304
- // THEN
305
- Template . fromStack ( stack ) . hasResourceProperties ( 'AWS::Lambda::Permission' , {
306
- 'Principal' : 's3.amazonaws.com' ,
307
- 'SourceAccount' : {
308
- 'Ref' : 'AWS::AccountId' ,
309
- } ,
310
- 'SourceArn' : 'arn:aws:s3:::some-bucket-not-in-this-account' ,
311
- } ) ;
312
- } ) ;
313
231
} ) ;
0 commit comments