/
template.yaml
95 lines (89 loc) · 2.38 KB
/
template.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
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