AWSTemplateFormatVersion: '2010-09-09' Transform: AWS::Serverless-2016-10-31 Description: Serverless pattern - S3 -> Lambda -> Polly # More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst Globals: Function: Timeout: 120 MemorySize: 128 Resources: TextToSpeechFunction: Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction Properties: CodeUri: src/ Handler: app.lambda_handler Runtime: python3.9 Events: S3Event: Type: S3 Properties: Bucket: !Ref InputBucket Events: s3:ObjectCreated:* Policies: - AWSLambdaBasicExecutionRole - Version: '2012-10-17' Statement: - Effect: Allow Action: - "polly:SynthesizeSpeech" - "polly:GetSpeechSynthesisTask" - "polly:GetLexicon" - "s3:GetObject" - "s3:PutObject" Resource: "*" InputBucket: Type: AWS::S3::Bucket Properties: BucketName: texttospeechinputbucket OutputBucket: Type: AWS::S3::Bucket Properties: BucketName: texttospeechoutputbucket Outputs: TSOutputBucket: Description: "The bucket with the converted audio file" Value: Ref: OutputBucket