-
Notifications
You must be signed in to change notification settings - Fork 0
/
template.yaml
166 lines (156 loc) · 4.02 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
Server support for video streaming app
Metadata:
esbuild-properties: &esbuild-properties
Format: esm
Minify: true
OutExtension:
- .js=.mjs
Target: es2020
Sourcemap: false
EntryPoints:
- index.mjs
Banner:
- js=import { createRequire } from 'module'; const require = createRequire(import.meta.url);
External:
- '@aws-sdk/*'
Loader:
- .hbs=text
Parameters:
MomentoApiKey:
Type: String
NoEcho: true
Connection:
Type: String
Description: Connection ARN for AppRunner <> GitHub
Globals:
Function:
Runtime: nodejs20.x
Architectures:
- arm64
Tracing: Active
Timeout: 15
MemorySize: 1024
CodeUri: functions
Environment:
Variables:
AWS_NODEJS_CONNECTION_REUSE_ENABLED: 1
Resources:
VideoApi:
Type: AWS::Serverless::HttpApi
Properties:
StageName: v1
DefinitionBody:
'Fn::Transform':
Name: AWS::Include
Parameters:
Location: ./openapi.yaml
WebhookFunction:
Type: AWS::Serverless::Function
Metadata:
BuildMethod: esbuild
BuildProperties:
<<: *esbuild-properties
EntryPoints:
- webhook.mjs
Properties:
Handler: webhook.handler
Policies:
- AWSLambdaBasicExecutionRole
Environment:
Variables:
MOMENTO_API_KEY: !Ref MomentoApiKey
CACHE_NAME: video
Events:
Api:
Type: HttpApi
Properties:
ApiId: !Ref VideoApi
Path: /data
Method: POST
DashboardFunction:
Type: AWS::Serverless::Function
Metadata:
BuildMethod: esbuild
BuildProperties:
<<: *esbuild-properties
EntryPoints:
- dashboard.mjs
Properties:
Handler: dashboard.handler
Policies:
- AWSLambdaBasicExecutionRole
Environment:
Variables:
MOMENTO_API_KEY: !Ref MomentoApiKey
CACHE_NAME: video
Events:
Api:
Type: HttpApi
Properties:
ApiId: !Ref VideoApi
Path: /dashboard
Method: GET
PlayerFunction:
Type: AWS::Serverless::Function
Metadata:
BuildMethod: esbuild
BuildProperties:
<<: *esbuild-properties
EntryPoints:
- player.mjs
Properties:
Handler: player.handler
Policies:
- AWSLambdaBasicExecutionRole
Environment:
Variables:
MOMENTO_API_KEY: !Ref MomentoApiKey
CACHE_NAME: video
Events:
Api:
Type: HttpApi
Properties:
ApiId: !Ref VideoApi
Path: /
Method: GET
VideoAppRunnerRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Statement:
- Effect: Allow
Principal:
Service: ['tasks.apprunner.amazonaws.com']
Action: ['sts:AssumeRole']
Path: /
Policies:
- PolicyName: RSSAppRunnerRole
PolicyDocument:
Statement:
- Effect: Allow
Action: ssm:GetParameters
Resource:
- !Sub arn:${AWS::Partition}:ssm:${AWS::Region}:${AWS::AccountId}:parameter/momento
HeartbeatService:
Type: AWS::AppRunner::Service
Properties:
SourceConfiguration:
AuthenticationConfiguration:
ConnectionArn: !Ref Connection
AutoDeploymentsEnabled: true
CodeRepository:
CodeConfiguration:
ConfigurationSource: REPOSITORY
RepositoryUrl: https://github.com/momentohq/demo-video-streaming
SourceCodeVersion:
Type: BRANCH
Value: main
InstanceConfiguration:
InstanceRoleArn: !GetAtt VideoAppRunnerRole.Arn
Outputs:
VideoBaseUrl:
Description: API Gateway endpoint for the video streaming API
Value: !Sub 'https://${VideoApi}.execute-api.${AWS::Region}.amazonaws.com/v1'