AWSTemplateFormatVersion: '2010-09-09' Transform: 'AWS::Serverless-2016-10-31' Description: 'Competition API deployment' Parameters: Env: Description: The environment name. Type: String Default: dev Resources: CompetitionFunction: Type: AWS::Serverless::Function Properties: CodeUri: ../../.. Environment: Variables: ENV: !Ref Env Events: GetById: Type: Api Properties: Path: '/competitions/{id}' Method: get Post: Type: Api Properties: Path: '/competitions' Method: post Ping: Type: Schedule Properties: Schedule: rate(5 minutes) Input: '{"httpMethod": "PING"}' FunctionName: !Sub '${AWS::StackName}-competition' Handler: src/main/js/handlers/competition.handler Policies: - AWSLambdaBasicExecutionRole - Version: 2012-10-17 Statement: - Action: - secretsmanager:GetSecretValue Effect: Allow Resource: '*' - Action: - kms:Decrypt Effect: Allow Resource: '*' Runtime: nodejs8.10 CompetitionFunctionLogRetention: Type: AWS::Logs::LogGroup Properties: LogGroupName: !Sub '/aws/lambda/${ CompetitionFunction}' RetentionInDays: 7 CompetitorFunction: Type: AWS::Serverless::Function Properties: CodeUri: ../../.. Environment: Variables: ENV: !Ref Env Events: GetById: Type: Api Properties: Path: '/competitors/{id}' Method: get Post: Type: Api Properties: Path: '/competitors' Method: post Ping: Type: Schedule Properties: Schedule: rate(5 minutes) Input: '{"httpMethod": "PING"}' FunctionName: !Sub '${AWS::StackName}-competitor' Handler: src/main/js/handlers/competitor.handler Policies: - AWSLambdaBasicExecutionRole - Version: 2012-10-17 Statement: - Action: - secretsmanager:GetSecretValue Effect: Allow Resource: '*' - Action: - kms:Decrypt Effect: Allow Resource: '*' Runtime: nodejs8.10 CompetitorFunctionLogRetention: Type: AWS::Logs::LogGroup Properties: LogGroupName: !Sub '/aws/lambda/${ CompetitorFunction}' RetentionInDays: 7 Outputs: CompetitionFunction: Description: The name of the Lambda function for the Competition model Value: !Ref CompetitionFunction Export: Name: !Sub '${AWS::StackName}-functions-Competition' CompetitionFunctionRole: Description: The name of the Lambda function role for the Competition model Value: !Ref CompetitionFunctionRole Export: Name: !Sub '${AWS::StackName}-roles-Competition' CompetitorFunction: Description: The name of the Lambda function for the Competitor model Value: !Ref CompetitorFunction Export: Name: !Sub '${AWS::StackName}-functions-Competitor' CompetitorFunctionRole: Description: The name of the Lambda function role for the Competitor model Value: !Ref CompetitorFunctionRole Export: Name: !Sub '${AWS::StackName}-roles-Competitor'