-
Notifications
You must be signed in to change notification settings - Fork 3
/
sam.yml
102 lines (88 loc) · 2.52 KB
/
sam.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
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
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Parameters:
Bucket:
Type: CommaDelimitedList
Default: "*"
DisableCOG:
Type: String
Default: "false"
AllowedValues:
- "true"
- "false"
DisableMosaic:
Type: String
Default: "true"
AllowedValues:
- "true"
- "false"
DisableSTAC:
Type: String
Default: "true"
AllowedValues:
- "true"
- "false"
LayerVersion:
Type: String
Default: 14
Resources:
TiTiler:
Type: AWS::Serverless::Function
Properties:
Runtime: python3.11
Handler: index.handler
Description: 'Titiler: Dynamic tiler'
Layers:
- !Sub arn:aws:lambda:${AWS::Region}:552819999234:layer:titiler:${LayerVersion}
InlineCode: |
import logging
from mangum import Mangum
from titiler.application.main import app
logging.getLogger("mangum.lifespan").setLevel(logging.ERROR)
logging.getLogger("mangum.http").setLevel(logging.ERROR)
handler = Mangum(app, lifespan="auto")
MemorySize: 1024
Timeout: 10
Policies:
- AWSLambdaExecute # Managed Policy
- Version: '2012-10-17' # Policy Document
Statement:
- Effect: Allow
Action:
- s3:GetObject
- s3:HeadObject
Resource:
!Split
- ','
- !Join
- ''
- - 'arn:aws:s3:::'
- !Join
- '/*,arn:aws:s3:::'
- !Ref Bucket
- '/*'
Environment:
Variables:
CPL_VSIL_CURL_ALLOWED_EXTENSIONS: '.tif,.TIF,.tiff'
GDAL_CACHEMAX: 200
GDAL_DISABLE_READDIR_ON_OPEN: EMPTY_DIR
GDAL_HTTP_MERGE_CONSECUTIVE_RANGES: YES
GDAL_HTTP_MULTIPLEX: YES
GDAL_HTTP_VERSION: 2
VSI_CACHE: TRUE
VSI_CACHE_SIZE: 536870912
CPL_VSIL_CURL_CACHE_SIZE: 200000000
GDAL_INGESTED_BYTES_AT_OPEN: 32768
TITILER_API_DISABLE_COG: !Ref DisableCOG
TITILER_API_DISABLE_STAC: !Ref DisableSTAC
TITILER_API_DISABLE_MOSAIC: !Ref DisableMosaic
Events:
API:
Type: HttpApi
Outputs:
LambdaFunc:
Description: Lambda Fucntion ARN
Value: !GetAtt TiTiler.Arn
Api:
Description: "Endpoint URL"
Value: !Sub "https://${ServerlessHttpApi}.execute-api.${AWS::Region}.amazonaws.com/"