@@ -110,7 +110,7 @@ export = {
110
110
111
111
'Access logging' ( test : Test ) {
112
112
// GIVEN
113
- const stack = new cdk . Stack ( undefined , undefined , { env : { region : 'us-east-1' } } ) ;
113
+ const stack = new cdk . Stack ( undefined , undefined , { env : { region : 'us-east-1' } } ) ;
114
114
const vpc = new ec2 . Vpc ( stack , 'Stack' ) ;
115
115
const bucket = new s3 . Bucket ( stack , 'AccessLoggingBucket' ) ;
116
116
const lb = new elbv2 . ApplicationLoadBalancer ( stack , 'LB' , { vpc } ) ;
@@ -140,26 +140,29 @@ export = {
140
140
Version : '2012-10-17' ,
141
141
Statement : [
142
142
{
143
- Action : [ "s3:PutObject*" , "s3:Abort*" ] ,
143
+ Action : [ "s3:PutObject*" , "s3:Abort*" ] ,
144
144
Effect : 'Allow' ,
145
- Principal : { AWS : { "Fn::Join" : [ "" , [ "arn:" , { Ref : "AWS::Partition" } , ":iam::127311923021:root" ] ] } } ,
146
- Resource : { "Fn::Join" : [ "" , [ { "Fn::GetAtt" : [ "AccessLoggingBucketA6D88F29" , "Arn" ] } , "/*" ] ] }
145
+ Principal : { AWS : { "Fn::Join" : [ "" , [ "arn:" , { Ref : "AWS::Partition" } , ":iam::127311923021:root" ] ] } } ,
146
+ Resource : {
147
+ "Fn::Join" : [ "" , [ { "Fn::GetAtt" : [ "AccessLoggingBucketA6D88F29" , "Arn" ] } , "/AWSLogs/" ,
148
+ { Ref : "AWS::AccountId" } , "/*" ] ]
149
+ }
147
150
}
148
151
]
149
152
}
150
153
} ) ) ;
151
154
152
155
// verify the ALB depends on the bucket *and* the bucket policy
153
156
expect ( stack ) . to ( haveResource ( 'AWS::ElasticLoadBalancingV2::LoadBalancer' , {
154
- DependsOn : [ 'AccessLoggingBucketPolicy700D7CC6' , 'AccessLoggingBucketA6D88F29' ]
157
+ DependsOn : [ 'AccessLoggingBucketPolicy700D7CC6' , 'AccessLoggingBucketA6D88F29' ]
155
158
} , ResourcePart . CompleteDefinition ) ) ;
156
159
157
160
test . done ( ) ;
158
161
} ,
159
162
160
163
'access logging with prefix' ( test : Test ) {
161
164
// GIVEN
162
- const stack = new cdk . Stack ( undefined , undefined , { env : { region : 'us-east-1' } } ) ;
165
+ const stack = new cdk . Stack ( undefined , undefined , { env : { region : 'us-east-1' } } ) ;
163
166
const vpc = new ec2 . Vpc ( stack , 'Stack' ) ;
164
167
const bucket = new s3 . Bucket ( stack , 'AccessLoggingBucket' ) ;
165
168
const lb = new elbv2 . ApplicationLoadBalancer ( stack , 'LB' , { vpc } ) ;
@@ -192,10 +195,13 @@ export = {
192
195
Version : '2012-10-17' ,
193
196
Statement : [
194
197
{
195
- Action : [ "s3:PutObject*" , "s3:Abort*" ] ,
198
+ Action : [ "s3:PutObject*" , "s3:Abort*" ] ,
196
199
Effect : 'Allow' ,
197
- Principal : { AWS : { "Fn::Join" : [ "" , [ "arn:" , { Ref : "AWS::Partition" } , ":iam::127311923021:root" ] ] } } ,
198
- Resource : { "Fn::Join" : [ "" , [ { "Fn::GetAtt" : [ "AccessLoggingBucketA6D88F29" , "Arn" ] } , "/prefix-of-access-logs*" ] ] }
200
+ Principal : { AWS : { "Fn::Join" : [ "" , [ "arn:" , { Ref : "AWS::Partition" } , ":iam::127311923021:root" ] ] } } ,
201
+ Resource : {
202
+ "Fn::Join" : [ "" , [ { "Fn::GetAtt" : [ "AccessLoggingBucketA6D88F29" , "Arn" ] } , "/prefix-of-access-logs/AWSLogs/" ,
203
+ { Ref : "AWS::AccountId" } , "/*" ] ]
204
+ }
199
205
}
200
206
]
201
207
}
0 commit comments