-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathtemplate.yaml
116 lines (105 loc) · 3.36 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
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
marblecutter-virtual
SAM Template for marblecutter-virtual
Parameters:
DomainName:
Type: String
Description: Endpoint name
AcmCertificateArn:
Type: String
Description: ACM Certificate ARN (must have been created in us-east-1)
Default: ""
Globals:
Api:
# API Gateway regional endpoints
EndpointConfiguration: REGIONAL
# enable CORS; to make more specific, change the origin wildcard
# to a particular domain name, e.g. "'www.example.com'"
Cors:
AllowMethods: "'*'"
AllowHeaders: "'*'"
AllowOrigin: "'*'"
# Send/receive binary data through the APIs
BinaryMediaTypes:
# This is equivalent to */* when deployed
- "*~1*"
Resources:
# Lambda function
MarblecutterVirtualFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: .
Policies: AmazonS3ReadOnlyAccess
Handler: virtual.lambda.handle
Runtime: python3.6
Environment:
Variables:
AWS_REQUEST_PAYER: requester
CPL_TMPDIR: /tmp
GDAL_CACHEMAX: 75%
GDAL_DATA: /var/task/rasterio/gdal_data
GDAL_DISABLE_READDIR_ON_OPEN: TRUE
GDAL_HTTP_MERGE_CONSECUTIVE_RANGES: YES
# requires nghttp2 support
GDAL_HTTP_VERSION: 2
VSI_CACHE: TRUE
VSI_CACHE_SIZE: 500000000
Timeout: 15
MemorySize: 1536
Events:
# API Gateway routes
ProxyApiRoot:
Type: Api
Properties:
Path: /
Method: ANY
ProxyApiGreedy:
Type: Api
Properties:
Path: /{proxy+}
Method: ANY
# CloudFront Distribution
CFDistribution:
Type: AWS::CloudFront::Distribution
Properties:
DistributionConfig:
Aliases:
- !Ref DomainName
Enabled: true
Comment: marblecutter-virtual
IPV6Enabled: true
Origins:
-
Id: MarblecutterVirtualApi
DomainName: !Sub "${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com"
CustomOriginConfig:
OriginProtocolPolicy: https-only
OriginCustomHeaders:
- HeaderName: X-Forwarded-Host
HeaderValue: !Ref DomainName
OriginPath: !Sub "/${ServerlessRestApi.Stage}"
DefaultCacheBehavior:
TargetOriginId: MarblecutterVirtualApi
ForwardedValues:
QueryString: true
Cookies:
Forward: none
ViewerProtocolPolicy: allow-all
# ViewerCertificate:
# AcmCertificateArn: !Ref AcmCertificateArn
# SslSupportMethod: sni-only
Outputs:
MarblecutterVirtualApi:
Description: "API Gateway endpoint URL for for marblecutter-virtual"
Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/${ServerlessRestApi.Stage}"
MarblecutterVirtualFunction:
Description: "marblecutter-virtual Lambda Function ARN"
Value: !GetAtt MarblecutterVirtualFunction.Arn
MarblecutterVirtualFunctionIamRole:
Description: "Implicit IAM Role created for marblecutter-virtual"
Value: !GetAtt MarblecutterVirtualFunctionRole.Arn
CFDistribution:
Description: Cloudfront Distribution Domain Name
Value: !GetAtt CFDistribution.DomainName