-
Notifications
You must be signed in to change notification settings - Fork 0
/
template.yml
75 lines (69 loc) · 1.75 KB
/
template.yml
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
AWSTemplateFormatVersion: "2010-09-09"
Transform: AWS::Serverless-2016-10-31
Parameters:
DomainName:
Type: String
ACMCertificateArn:
Type: String
Resources:
RecordsTable:
Type: AWS::DynamoDB::Table
Properties:
TimeToLiveSpecification:
# data rentention is one day, implemented in add.go
Enabled: true
AttributeName: expires
AttributeDefinitions:
- AttributeName: id
AttributeType: S
- AttributeName: created
AttributeType: N
KeySchema:
- AttributeName: id
KeyType: HASH
- AttributeName: created
KeyType: RANGE
BillingMode: PAY_PER_REQUEST
RootBucket:
Type: AWS::S3::Bucket
Properties:
# data retention is one day
LifecycleConfiguration:
Rules:
- ExpirationInDays: 1
Status: Enabled
MainFunction:
Type: AWS::Serverless::Function
Properties:
Architectures:
- arm64
CodeUri: .
Handler: main
Runtime: provided.al2
Policies:
- DynamoDBCrudPolicy:
TableName: !Ref RecordsTable
- S3CrudPolicy:
BucketName: !Ref RootBucket
Environment:
Variables:
TABLE_NAME: !Ref RecordsTable
BUCKET_NAME: !Ref RootBucket
Events:
CatchAll:
Type: HttpApi
Properties:
ApiId: !Ref Gateway
Path: /{proxy+}
Method: ANY
Metadata:
BuildMethod: makefile
Gateway:
Type: AWS::Serverless::HttpApi
Properties:
Domain:
DomainName: !Ref DomainName
CertificateArn: !Ref ACMCertificateArn
Outputs:
GatewayEndPoint:
Value: !Sub "https://${Gateway}.execute-api.${AWS::Region}.amazonaws.com/"