#Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. #SPDX-License-Identifier: MIT-0 AWSTemplateFormatVersion: '2010-09-09' Transform: AWS::Serverless-2016-10-31 Description: sam stack to create the Parameters: S3BucketName: Description: S3 path pointing to raw data Type: String MetricsNameSpace: Description: MetricsNameSpace Type: String Resources: LambdaRole: Type: AWS::IAM::Role Properties: AssumeRolePolicyDocument: Version: 2012-10-17 Statement: - Effect: Allow Principal: Service: lambda.amazonaws.com Action: sts:AssumeRole Path: / Policies: - PolicyName: lambdapolicy PolicyDocument: Version: 2012-10-17 Statement: - Effect: Allow Action: - sns:* - sqs:* Resource: '*' - Effect: Allow Action: - cloudwatch:* - logs:DescribeLogStreams - logs:GetLogEvents Resource: '*' - Effect: Allow Action: - logs:CreateLogGroup Resource: Fn::Sub: arn:aws:logs:${AWS::Region}:${AWS::AccountId}:* - Effect: Allow Action: - s3:* - s3:ListBucket Resource: - Fn::Sub: arn:aws:s3:::${S3BucketName} - Fn::Sub: arn:aws:s3:::${S3BucketName}/* - arn:aws:s3:::covid19-lake - arn:aws:s3:::covid19-lake/* - Effect: Allow Action: - logs:CreateLogStream - logs:PutLogEvents Resource: Fn::Sub: arn:aws:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/lambda/* LambdaInvokePermission: Type: 'AWS::Lambda::Permission' Properties: FunctionName: !GetAtt Lambda.Arn Action: 'lambda:InvokeFunction' Principal: 's3.amazonaws.com' SourceAccount: !Sub ${AWS::AccountId} SourceArn: !Sub arn:aws:s3:::${S3BucketName} Lambda: Type: 'AWS::Serverless::Function' Properties: Description: check existing Forecast model performance and publish the result as metric Runtime: python3.7 Role: !GetAtt LambdaRole.Arn FunctionName: sam_forecast_forecastMetrics Handler: forecastMetrics.onEventHandler CodeUri: ./forecastMetrics/ MemorySize: 256 Timeout: 30 ReservedConcurrentExecutions: 1 Events: BySchedule: Type: Schedule Properties: Schedule: rate(12 hours) Environment: Variables: S3BucketName: !Ref S3BucketName MetricsNameSpace: !Ref MetricsNameSpace