-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate.yaml
82 lines (78 loc) · 2.25 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
AWSTemplateFormatVersion: 2010-09-09
Transform: AWS::Serverless-2016-10-31
Description: Lambda@Edge functions
Globals:
Function:
Timeout: 15
Resources:
RestfulApiHandler:
Type: AWS::Serverless::Function
Properties:
Description: Handler example with preconfigured routes and middleware.
CodeUri: ./restfulApiHandler
Handler: app.handler
Runtime: nodejs20.x
AutoPublishAlias: Auto
Role: !GetAtt LambdaEdgeRole.Arn
Metadata:
BuildMethod: makefile
LambdaEdgeRole:
Type: AWS::IAM::Role
Properties:
RoleName: !Sub ${AWS::StackName}-restfulApiHandler
AssumeRolePolicyDocument:
Version: 2012-10-17
Statement:
Effect: Allow
Principal:
Service:
- lambda.amazonaws.com
- edgelambda.amazonaws.com
Action: sts:AssumeRole
ManagedPolicyArns:
- arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
CloudFrontConfig:
Type: AWS::CloudFront::Distribution
Properties:
DistributionConfig:
Comment: RestfulApiHandler
Enabled: true
Origins:
-
Id: restfulApiHandler
DomainName: aws.amazon.com
CustomOriginConfig:
HTTPPort: 443
OriginProtocolPolicy: https-only
DefaultCacheBehavior:
TargetOriginId: restfulApiHandler
ForwardedValues:
QueryString: false
Cookies:
Forward: none
ViewerProtocolPolicy: allow-all
CacheBehaviors:
-
TargetOriginId: restfulApiHandler
PathPattern: '/api*'
AllowedMethods:
- GET
- HEAD
- OPTIONS
- PUT
- PATCH
- POST
- DELETE
ForwardedValues:
Headers:
- Accept
- Authorization
QueryString: false
Cookies:
Forward: none
LambdaFunctionAssociations:
-
EventType: origin-request
LambdaFunctionARN: !Ref RestfulApiHandler.Version
IncludeBody: true
ViewerProtocolPolicy: allow-all