Skip to content

Commit de19c11

Browse files
Merge pull request #12 from Crowdhandler/improvement/one-click-deploy
Improvement/one click deploy
2 parents b7d7846 + 3d485a0 commit de19c11

12 files changed

Lines changed: 3943 additions & 326 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ jspm_packages
99
# custom
1010
dummy-payloads
1111
dist/*.json
12+
garnished_dist/*
1213
.DS_Store

cloudformation/cloudformation.yaml

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
AWSTemplateFormatVersion: '2010-09-09'
2+
Description: >
3+
CloudFormation Template for creating the Lambda functions for crowdhandler.
4+
This template deploys three functions using code stored in S3:
5+
- crowdhandler-viewerRequest (from viewerRequest.zip)
6+
- crowdhandler-originResponse (from originResponse.zip)
7+
- crowdhandler-originOverride (from originOverride.zip)
8+
It publishes a version of each function—necessary before attaching them to Lambda@Edge.
9+
The S3 bucket is fixed as "cloudfront-integration-bundles" and the function code keys are derived from the PublicKey parameter.
10+
11+
Parameters:
12+
PublicKey:
13+
Type: String
14+
Description: "The public key used to scope the S3 key. The code packages are expected at dist/<PublicKey>/..."
15+
16+
Resources:
17+
LambdaExecutionRole:
18+
Type: AWS::IAM::Role
19+
Properties:
20+
AssumeRolePolicyDocument:
21+
Version: "2012-10-17"
22+
Statement:
23+
- Effect: Allow
24+
Principal:
25+
Service:
26+
- lambda.amazonaws.com
27+
- edgelambda.amazonaws.com
28+
Action: sts:AssumeRole
29+
Policies:
30+
- PolicyName: crowdhandler
31+
PolicyDocument:
32+
Version: "2012-10-17"
33+
Statement:
34+
- Effect: Allow
35+
Action: logs:CreateLogGroup
36+
Resource: arn:aws:logs:*:*:*
37+
- Effect: Allow
38+
Action:
39+
- logs:CreateLogStream
40+
- logs:PutLogEvents
41+
Resource: arn:aws:logs:*:*:log-group:*:*
42+
43+
CrowdhandlerViewerRequestLambda:
44+
Type: AWS::Lambda::Function
45+
Properties:
46+
FunctionName: crowdhandler-viewerRequest
47+
Runtime: nodejs22.x
48+
Role: !GetAtt LambdaExecutionRole.Arn
49+
Handler: handlerViewerRequest.viewerRequest
50+
Code:
51+
S3Bucket: cloudfront-integration-bundles
52+
S3Key: !Sub "dist/${PublicKey}/viewerRequest.zip"
53+
MemorySize: 128
54+
Timeout: 5
55+
56+
CrowdhandlerOriginResponseLambda:
57+
Type: AWS::Lambda::Function
58+
Properties:
59+
FunctionName: crowdhandler-originResponse
60+
Runtime: nodejs22.x
61+
Role: !GetAtt LambdaExecutionRole.Arn
62+
Handler: handlerOriginResponse.originResponse
63+
Code:
64+
S3Bucket: cloudfront-integration-bundles
65+
S3Key: !Sub "dist/${PublicKey}/originResponse.zip"
66+
MemorySize: 128
67+
Timeout: 30
68+
69+
CrowdhandlerOriginOverrideLambda:
70+
Type: AWS::Lambda::Function
71+
Properties:
72+
FunctionName: crowdhandler-originOverride
73+
Runtime: nodejs22.x
74+
Role: !GetAtt LambdaExecutionRole.Arn
75+
Handler: handlerOriginOverride.originOverride
76+
Code:
77+
S3Bucket: cloudfront-integration-bundles
78+
S3Key: !Sub "dist/${PublicKey}/originOverride.zip"
79+
MemorySize: 128
80+
Timeout: 30
81+
82+
# Publish a version of each function for Lambda@Edge association
83+
CrowdhandlerViewerRequestLambdaVersion:
84+
Type: AWS::Lambda::Version
85+
Properties:
86+
FunctionName: !Ref CrowdhandlerViewerRequestLambda
87+
88+
CrowdhandlerOriginResponseLambdaVersion:
89+
Type: AWS::Lambda::Version
90+
Properties:
91+
FunctionName: !Ref CrowdhandlerOriginResponseLambda
92+
93+
CrowdhandlerOriginOverrideLambdaVersion:
94+
Type: AWS::Lambda::Version
95+
Properties:
96+
FunctionName: !Ref CrowdhandlerOriginOverrideLambda
97+
98+
Outputs:
99+
ViewerRequestLambdaVersionARN:
100+
Description: "The ARN of the published version of the crowdhandler-viewerRequest function."
101+
Value: !GetAtt CrowdhandlerViewerRequestLambdaVersion.Version
102+
103+
OriginResponseLambdaVersionARN:
104+
Description: "The ARN of the published version of the crowdhandler-originResponse function."
105+
Value: !GetAtt CrowdhandlerOriginResponseLambdaVersion.Version
106+
107+
OriginOverrideLambdaVersionARN:
108+
Description: "The ARN of the published version of the crowdhandler-originOverride function."
109+
Value: !GetAtt CrowdhandlerOriginOverrideLambdaVersion.Version

dist/originOverride.zip

248 Bytes
Binary file not shown.

dist/viewerRequest.zip

117 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)