@@ -539,7 +539,18 @@ export class StacksCloud extends Stack {
539
539
} ,
540
540
} )
541
541
542
- this . storage . emailBucket ?. addToResourcePolicy ( bucketPolicyStatement )
542
+ this . storage . emailBucket . addToResourcePolicy ( bucketPolicyStatement )
543
+ // Grant SES permission to write to the S3 bucket
544
+ this . storage . emailBucket . addToResourcePolicy ( new iam . PolicyStatement ( {
545
+ principals : [ sesPrincipal ] ,
546
+ actions : [ 's3:PutObject' ] ,
547
+ resources : [ this . storage . emailBucket . arnForObjects ( '*' ) ] ,
548
+ conditions : {
549
+ StringEquals : {
550
+ 'aws:Referer' : this . account ,
551
+ } ,
552
+ } ,
553
+ } ) )
543
554
544
555
const iamGroup = new iam . Group ( this , 'IAMGroup' , {
545
556
groupName : `${ this . appName } -${ appEnv } -email-management-s3-group` ,
@@ -784,18 +795,6 @@ export class StacksCloud extends Stack {
784
795
785
796
lambdaEmailConverterRole . addToPolicy ( converterS3PolicyStatement )
786
797
787
- // Grant SES permission to write to the S3 bucket
788
- this . storage . emailBucket . addToResourcePolicy ( new iam . PolicyStatement ( {
789
- principals : [ new iam . ServicePrincipal ( 'ses.amazonaws.com' ) ] ,
790
- actions : [ 's3:PutObject' ] ,
791
- resources : [ this . storage . emailBucket . arnForObjects ( '*' ) ] ,
792
- conditions : {
793
- StringEquals : {
794
- 'aws:Referer' : this . account ,
795
- } ,
796
- } ,
797
- } ) )
798
-
799
798
this . storage . emailBucket . addEventNotification ( s3 . EventType . OBJECT_CREATED_PUT , new s3n . LambdaDestination ( lambdaEmailInbound ) , { prefix : 'tmp/email_in' } )
800
799
this . storage . emailBucket . addEventNotification ( s3 . EventType . OBJECT_CREATED_PUT , new s3n . LambdaDestination ( lambdaEmailOutbound ) , { prefix : 'tmp/email_out/json' } )
801
800
this . storage . emailBucket . addEventNotification ( s3 . EventType . OBJECT_CREATED_COPY , new s3n . LambdaDestination ( lambdaEmailConverter ) , { prefix : 'sent/' } )
0 commit comments