forked from dengmingtong/aws-cloudfront-extensions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
template.yaml
97 lines (86 loc) · 3.63 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
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
(SO8120)
multiple-origin-IP-retry
The domain name of the customer's origin site has multiple IPs. When the first IP fails to access, it needs to poll other IPs until the return to the source is successful, or all IPs fail after polling.
# More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst
Globals:
Function:
Timeout: 30
Tags:
Publisher: AWS
Metadata:
AWS::ServerlessRepo::Application:
Name: multiple-origin-IP-retry
Description: The Lambda@Edge is designed to let customer set multiple candidate IP Addresses to try when the origin failed to fetch the content
Author: AWS
SpdxLicenseId: Apache-2.0
LicenseUrl: LICENSE.txt
ReadmeUrl: README.md
Labels: ['gcr','gcr-solutions','cloudfront','cloudfront+','aws-cloudfront-extensions','edge','lambda-edge', 'aws']
HomePageUrl: https://www.amazonaws.cn/en/solutions/lambda-edge-collection-for-cloudfront/
SemanticVersion: 1.0.0
SourceCodeUrl: https://github.com/awslabs/aws-cloudfront-extensions/edge/nodejs/multiple-origin-IP-retry
Parameters:
OriginIPList:
Type: String
Default: ""
Description: "Origin IP list for retry, use semicolon to separate multiple IP addresses"
OriginProtocol:
Type: String
Default: ""
Description: "Origin protocol, https or http"
Resources:
MultipleOriginIPRetry:
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: multiple-origin-IP-retry/
Handler: app.handler
Runtime: nodejs12.x
Role: !GetAtt EdgeFunctionRole.Arn
EdgeFunctionRole:
Type: AWS::IAM::Role
Properties:
RoleName: !Sub ${AWS::StackName}-edgeFunction
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
- arn:aws:iam::aws:policy/AWSXrayWriteOnlyAccess
- arn:aws:iam::aws:policy/AWSLambda_FullAccess
UpdateEdgeCodeFunction:
Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
DependsOn: MultipleOriginIPRetry
Properties:
CodeUri: 's3://aws-cloudfront-extension-lambda-edge/update-lambda-function.zip'
Handler: index.handler
Runtime: python3.7
Role: !GetAtt EdgeFunctionRole.Arn
UpdateConfigCustom:
Type: Custom::UpdateConfigCustom
DependsOn: UpdateEdgeCodeFunction
Properties:
ServiceToken: !GetAtt UpdateEdgeCodeFunction.Arn
SourceUrl: 'https://aws-cloudfront-extension-lambda-edge.s3.amazonaws.com/edge/multiple-origin-IP-retry/multiple-origin-IP-retry.zip'
EdgeFunctionArn: !GetAtt MultipleOriginIPRetry.Arn
HandlerFileName: 'app.js'
PARA_ORIGINIPLIST: !Ref OriginIPList
PARA_ORIGINPROTOCOL: !Ref OriginProtocol
Outputs:
MultipleOriginIPRetry:
Description: "Lambda Edge function ARN"
Value: !GetAtt MultipleOriginIPRetry.Arn
MultipleOriginIPRetryIamRole:
Description: "Implicit IAM Role created for Simple Lambda Edge function"
Value: !GetAtt EdgeFunctionRole.Arn
SolutionId:
Description: "Solution id"
Value: "SO8120"