-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate.yaml
96 lines (88 loc) · 3.31 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
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
Mapbox Tile Server
Based on Sample Sam Template
# More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst
Globals:
Function:
Timeout: 3
Parameters:
tilebucket:
Default: "qfes-mapbox-tiles"
Description: "The bucket to fetch tiles from"
Type: "String"
AllowedValues:
- "qfes-mapbox-tiles"
- "qfes-mapbox-tiles-test"
endpoints:
Default: "a.tiles.qfesanalytics.com,tiles.qfesanalytics.com"
Description: "The endpoints to be returned to the tile requester (for sharding support)"
Type: "String"
AllowedValues:
- "test.tiles.qfesanalytics.com"
- "a.tiles.qfesanalytics.com,tiles.qfesanalytics.com"
domainname:
Default: "test.tiles.qfesanalytics.com"
Description: "The domain name to be bound to the API"
Type: "String"
Resources:
MapboxTileServerFunction:
Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
Properties:
CodeUri: dist/
Handler: index.handler
Runtime: nodejs14.x
PackageType: Zip
Timeout: 5
MemorySize: 512
Architectures:
- x86_64
Events:
TileRequest:
Type: HttpApi # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
Properties:
ApiId: !Ref MapboxTileServerHttpApi # per https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-httpapi.html
# Properties:
# Path: /
# Method: get
# No path or method should give us a default function that handles all calls
Policies:
- S3ReadPolicy:
BucketName:
Ref: tilebucket
Environment:
Variables:
AWS_NODEJS_CONNECTION_REUSE_ENABLED: true
BUCKET:
Ref: tilebucket
ENDPOINTS:
Ref: endpoints
MapboxTileServerHttpApi:
Type: AWS::Serverless::HttpApi
Properties:
Domain:
DomainName:
Ref: domainname
CertificateArn: arn:aws:acm:ap-southeast-2:682936945876:certificate/2d9ce1da-a171-4451-9250-4afbe81df62e
Route53:
HostedZoneId: Z07369202AZX5L101LI7T
Outputs:
# This is an optional section that creates references to these pieces of the app,
# since they may be useful to have handy for integrations with other things.
# Put in per recommendation of SAM examples.
MapboxTileServerHttpApiUrl:
Description: "URL for Mapbox Tile Server"
Value: !Sub "https://${MapboxTileServerHttpApi}.execute-api.${AWS::Region}.${AWS::URLSuffix}"
MapboxTileServerHttpApiId:
Description: "Api Id for MapboxTileServerHttpApi"
Value:
Ref: MapboxTileServerHttpApi
MapboxTileSeverFunction:
Description: "Mapbox Tile Server Function ARN"
Value: !GetAtt MapboxTileServerFunction.Arn
# This is the function defined above
MapBoxTileServerFunctionIamRole:
Description: "Implicit IAM Role created for Mapbox Tile Server function"
Value: !GetAtt MapboxTileServerFunctionRole.Arn
# This is implicitly created