AWSTemplateFormatVersion: 2010-09-09 Metadata: AWS::CloudFormation::Interface: ParameterGroups: - Label: default: "S3 Information" Parameters: - CodeS3BucketPrefix - CodeS3Key - Label: default: "Tags" Parameters: - CheckTags - TagUsage - Label: default: "CloudWatch Event Rule" Parameters: - ScheduleExpression Parameters: CodeS3BucketPrefix: Type: String CodeS3Key: Type: String Default: lambda.zip CheckTags: Type: String Default: "[]" ScheduleExpression: Type: String Default: rate(1 hour) TagUsage: Type: String Default: Include AllowedValues: - Include - Exclude Resources: RateEvent: DependsOn: AGAProtectionLambdaPolicy Type: "AWS::Events::Rule" Properties: Description: CheckRoute53HostedZoneShieldProtection Name: Route53HostedZoneShieldProtection ScheduleExpression: !Ref ScheduleExpression Targets: - Arn: !GetAtt AGAProtectionLambda.Arn Id: CheckRoute53HostedZoneShieldProtection R53HostedZoneProtectionEventPermissions: Type: "AWS::Lambda::Permission" Properties: FunctionName: !GetAtt AGAProtectionLambda.Arn Action: "lambda:InvokeFunction" Principal: events.amazonaws.com SourceArn: !GetAtt RateEvent.Arn AGAProtectionLambdaRole: Type: "AWS::IAM::Role" Properties: AssumeRolePolicyDocument: Version: 2012-10-17 Statement: - Effect: Allow Principal: Service: - lambda.amazonaws.com Action: - "sts:AssumeRole" Path: / AGAProtectionLambdaPolicy: Type: "AWS::IAM::Policy" Metadata: cfn_nag: rules_to_suppress: - id: W12 reason: "all resources required" Properties: PolicyName: LocalPolicy PolicyDocument: Version: 2012-10-17 Statement: - Effect: Allow Action: - "logs:CreateLogGroup" - "logs:CreateLogStream" - "logs:PutLogEvents" Resource: "arn:aws:logs:*:*:*" - Effect: Allow Action: - "globalaccelerator:ListTagsForResource" - "globalaccelerator:ListAccelerators" - "globalaccelerator:DescribeAccelerator" - "shield:ListProtections" - "shield:CreateProtection" - "shield:DescribeProtection" - "shield:DeleteProtection" Resource: "*" Roles: - !Ref AGAProtectionLambdaRole AGAProtectionLambda: Type: "AWS::Lambda::Function" Metadata: cfn_nag: rules_to_suppress: - id: W58 reason: "Permissions granted, CFN_Nag not parsing correctly?" - id: W89 reason: "Not applicable for use case" - id: W92 reason: "Not applicable for use case" Properties: Runtime: python3.7 Role: !GetAtt AGAProtectionLambdaRole.Arn Handler: fms/global-accelerator-protection/index.lambda_handler Timeout: 300 Code: S3Bucket: !Sub "${CodeS3BucketPrefix}-${AWS::Region}" S3Key: !Ref CodeS3Key Environment: Variables: checkTags: !Ref CheckTags TagUsage: !Ref TagUsage