11AWSTemplateFormatVersion : ' 2010-09-09'
22Transform : AWS::Serverless-2016-10-31
33Description : Lambda Function for auto enable s3 logs for S3 Buckets, VPCs, Subnets,
4- Network Interfaces and Application load balancer.
4+ Network Interfaces, Application load balancer and Classic load balancer
55Globals :
66 Function :
77 Timeout : 300
@@ -24,35 +24,35 @@ Metadata:
2424 - s3logging
2525 - flowlogs
2626 Name : sumologic-s3-logging-auto-enable
27- SemanticVersion : 1.0.2
27+ SemanticVersion : 1.0.3
2828 SourceCodeUrl : https://github.com/SumoLogic/sumologic-aws-lambda/tree/master/awsautoenableS3Logging
29- LicenseUrl : s3://appdevstore/AutoEnableS3Logs/v1.0.2 /978602b5b9ec16f8bab0e38fd6b3998f
30- ReadmeUrl : s3://appdevstore/AutoEnableS3Logs/v1.0.2 /d05d411471e0bb4db3389f2523f515f0
29+ LicenseUrl : s3://appdevstore/AutoEnableS3Logs/v1.0.3 /978602b5b9ec16f8bab0e38fd6b3998f
30+ ReadmeUrl : s3://appdevstore/AutoEnableS3Logs/v1.0.3 /d05d411471e0bb4db3389f2523f515f0
3131 SpdxLicenseId : Apache-2.0
3232Mappings :
3333 Region2ELBAccountId :
3434 us-east-1 :
3535 AccountId : ' 127311923021'
3636 us-east-2 :
37- AccountId : 033677994240
37+ AccountId : ' 033677994240'
3838 us-west-1 :
39- AccountId : 027434742980
39+ AccountId : ' 027434742980'
4040 us-west-2 :
4141 AccountId : ' 797873946194'
4242 af-south-1 :
43- AccountId : 098369216593
43+ AccountId : ' 098369216593'
4444 ca-central-1 :
4545 AccountId : ' 985666609251'
4646 eu-central-1 :
47- AccountId : 054676820928
47+ AccountId : ' 054676820928'
4848 eu-west-1 :
4949 AccountId : ' 156460612806'
5050 eu-west-2 :
5151 AccountId : ' 652711504416'
5252 eu-south-1 :
5353 AccountId : ' 635631232127'
5454 eu-west-3 :
55- AccountId : 009996457667
55+ AccountId : ' 009996457667'
5656 eu-north-1 :
5757 AccountId : ' 897822967062'
5858 ap-east-1 :
@@ -74,7 +74,7 @@ Mappings:
7474 sa-east-1 :
7575 AccountId : ' 507241528517'
7676 us-gov-west-1 :
77- AccountId : 048591011584
77+ AccountId : ' 048591011584'
7878 us-gov-east-1 :
7979 AccountId : ' 190560391635'
8080 cn-north-1 :
@@ -86,12 +86,14 @@ Parameters:
8686 Type : String
8787 Description : S3 - To Enable S3 Audit Logging for new S3 buckets. VPC - To Enable
8888 VPC flow logs for new VPC, Subnets and Network Interfaces. ALB - To Enable S3
89- Logging for new Application Load Balancer.
89+ Logging for new Application Load Balancer. ELB - To Enable S3 logging for new
90+ Classic Load Balancer
9091 AllowedPattern : .+
9192 AllowedValues :
9293 - S3
9394 - VPC
9495 - ALB
96+ - ELB
9597 AutoEnableResourceOptions :
9698 Type : String
9799 Description : New - Automatically enables S3 logging for newly created AWS resources
@@ -136,6 +138,12 @@ Conditions:
136138 - Ref : AutoEnableLogging
137139 - ALB
138140 - Condition : auto_enable_new
141+ enable_elb_logging :
142+ Fn::And :
143+ - Fn::Equals :
144+ - Ref : AutoEnableLogging
145+ - ELB
146+ - Condition : auto_enable_new
139147 enable_s3_buckets_logging :
140148 Fn::And :
141149 - Fn::Equals :
@@ -213,7 +221,7 @@ Resources:
213221 Type : AWS::Serverless::Function
214222 Condition : auto_enable_new
215223 Properties :
216- CodeUri : s3://appdevstore/sumo_app_utils/v2.0.2 /sumo_app_utils.zip
224+ CodeUri : s3://appdevstore/sumo_app_utils/v2.0.8 /sumo_app_utils.zip
217225 Handler : awsresource.enable_s3_logs
218226 Runtime : python3.7
219227 Role :
@@ -379,13 +387,61 @@ Resources:
379387 - EnableNewAWSResourcesLambda
380388 - Arn
381389 Id : Main
390+ AutoEnableElbLogEventsInvokePermission :
391+ Type : AWS::Lambda::Permission
392+ Condition : enable_elb_logging
393+ Properties :
394+ Action : lambda:InvokeFunction
395+ FunctionName :
396+ Ref : EnableNewAWSResourcesLambda
397+ Principal : events.amazonaws.com
398+ SourceArn :
399+ Fn::GetAtt :
400+ - AutoEnableElbLogEventsRuleTrigger
401+ - Arn
402+ AutoEnableElbLogEventsRuleTrigger :
403+ Type : AWS::Events::Rule
404+ Condition : enable_elb_logging
405+ Properties :
406+ Description : Auto-Enable S3 logging for ELB classic resources with Lambda from
407+ events
408+ EventPattern :
409+ source :
410+ - aws.elasticloadbalancing
411+ detail-type :
412+ - AWS API Call via CloudTrail
413+ detail :
414+ eventSource :
415+ - elasticloadbalancing.amazonaws.com
416+ eventName :
417+ - CreateLoadBalancer
418+ Name :
419+ Fn::Join :
420+ - ' '
421+ - - sumo-logic-elb-s3-
422+ - Fn::Select :
423+ - 0
424+ - Fn::Split :
425+ - ' -'
426+ - Fn::Select :
427+ - 2
428+ - Fn::Split :
429+ - /
430+ - Ref : AWS::StackId
431+ State : ENABLED
432+ Targets :
433+ - Arn :
434+ Fn::GetAtt :
435+ - EnableNewAWSResourcesLambda
436+ - Arn
437+ Id : Main
382438 EnableExisitngAWSResourcesLambda :
383439 Type : AWS::Serverless::Function
384440 Condition : auto_enable_existing
385441 Properties :
386442 Handler : main.handler
387443 Runtime : python3.7
388- CodeUri : s3://appdevstore/sumo_app_utils/v2.0.2 /sumo_app_utils.zip
444+ CodeUri : s3://appdevstore/sumo_app_utils/v2.0.8 /sumo_app_utils.zip
389445 MemorySize : 128
390446 Timeout : 900
391447 Role :
@@ -407,7 +463,10 @@ Resources:
407463 - Fn::If :
408464 - enable_vpc_flow_logs_logging
409465 - vpc
410- - elbv2
466+ - Fn::If :
467+ - enable_alb_logging
468+ - elbv2
469+ - elb
411470 BucketName :
412471 Ref : BucketName
413472 Filter :
0 commit comments