AWSTemplateFormatVersion: '2010-09-09' Transform: AWS::Serverless-2016-10-31 Description: patterns-audio-analyzer Parameters: InputBucketName: Type: String Default: 'patterns-audio-analyzer' Globals: Function: Timeout: 10 Resources: InputS3Bucket: Type: AWS::S3::Bucket Properties: BucketName: !Ref InputBucketName ResultsDDBtable: Type: AWS::DynamoDB::Table Properties: AttributeDefinitions: - AttributeName: partitionKey AttributeType: S KeySchema: - AttributeName: partitionKey KeyType: HASH BillingMode: PAY_PER_REQUEST SentimentFunction: Type: AWS::Serverless::Function Properties: CodeUri: sentimentFunction/ Handler: app.handler Runtime: nodejs12.x MemorySize: 128 Environment: Variables: DDBtable: !Ref ResultsDDBtable Policies: - DynamoDBCrudPolicy: TableName: !Ref ResultsDDBtable - S3ReadPolicy: BucketName: !Ref InputBucketName - Statement: - Sid: comprehendDetectSentimentPolicy Effect: Allow Action: - comprehend:DetectSentiment Resource: '*' Events: FileUpload: Type: S3 Properties: Bucket: !Ref InputS3Bucket Events: s3:ObjectCreated:* Filter: S3Key: Rules: - Name: suffix Value: '.json' TranscribeFunction: Type: AWS::Serverless::Function Properties: CodeUri: transcribeFunction/ Handler: app.handler Runtime: nodejs12.x MemorySize: 128 Policies: - S3CrudPolicy: BucketName: !Ref InputBucketName - Statement: - Effect: Allow Resource: '*' Action: - transcribe:StartTranscriptionJob - cloudwatch:GetMetricStatistics - cloudwatch:ListMetrics Events: FileUpload: Type: S3 Properties: Bucket: !Ref InputS3Bucket Events: s3:ObjectCreated:* Filter: S3Key: Rules: - Name: suffix Value: '.mp3' Outputs: S3BucketName: Description: Transcriber S3 bucket Value: !Ref InputS3Bucket