AWSTemplateFormatVersion: '2010-09-09' Transform: 'AWS::Serverless-2016-10-31' Description: An example application that translates text file contents. Resources: TranslateFileFunction: Type: 'AWS::Serverless::Function' Properties: FunctionName: TranslateFile Handler: app.lambda_handler Runtime: python3.7 CodeUri: src/translate_file Description: A Lambda function that translates text file contents. Timeout: 120 Policies: - S3ReadPolicy: # Need to specify bucket name to avoid a circular dependency # More details: https://aws.amazon.com/blogs/infrastructure-and-automation/handling-circular-dependency-errors-in-aws-cloudformation/ BucketName: !Sub "translate-file-bucket-${AWS::AccountId}" - Statement: - Sid: TranslateText Effect: Allow Action: - translate:TranslateText - comprehend:DetectDominantLanguage Resource: '*' Events: FileUploadedEvent: Type: S3 Properties: Bucket: !Ref FileBucket Events: s3:ObjectCreated:* FileBucket: Type: AWS::S3::Bucket Properties: BucketName: !Sub "translate-file-bucket-${AWS::AccountId}"