Skip to content

Commit 9a2005e

Browse files
committed
simplify deployment because CF can package layers
1 parent 4884f8c commit 9a2005e

File tree

4 files changed

+35
-19
lines changed

4 files changed

+35
-19
lines changed

LICENSE.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
MIT License
2+
3+
Copyright 2020 Aleksandar Simovic <https://serverless.pub>
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6+
7+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8+
9+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
10+
© 2020 GitHub, Inc.

Makefile

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
DEPLOYMENT_BUCKET_NAME ?= desole-packaging
2-
DEPLOYMENT_KEY := $(shell echo s3-deployment-$$RANDOM.zip)
3-
STACK_NAME ?= s3-deployment
4-
51
clean:
62
rm -rf build
73

@@ -14,10 +10,9 @@ build/python/deployer.py: src/deployer.py build/python
1410
build/python/requests: build/python
1511
pip install requests --target build/python
1612

17-
build/layer.zip: build/python/deployer.py build/python/requests
18-
cd build/ && zip -r layer.zip python
13+
output.yml: cloudformation/template.yml build/python/requests build/python/deployer.py
14+
aws cloudformation package --template-file $< --output-template-file $@ --s3-bucket $(DEPLOYMENT_BUCKET_NAME)
1915

20-
deploy: cloudformation/template.yml build/layer.zip
21-
aws s3 cp build/layer.zip s3://$(DEPLOYMENT_BUCKET_NAME)/$(DEPLOYMENT_KEY)
22-
aws cloudformation deploy --template-file cloudformation/template.yml --stack-name $(STACK_NAME) --capabilities CAPABILITY_IAM --parameter-overrides DeploymentBucketName=$(DEPLOYMENT_BUCKET_NAME) DeploymentKey=$(DEPLOYMENT_KEY) LayerName=$(STACK_NAME)
16+
deploy: output.yml
17+
aws cloudformation deploy --template-file $< --stack-name $(STACK_NAME) --capabilities CAPABILITY_IAM
2318
aws cloudformation describe-stacks --stack-name $(STACK_NAME) --query Stacks[].Outputs[].OutputValue --output text

cloudformation/README-SAR.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# CloudFormation Deploy to S3
2+
3+
Deploy and publish Frontend SPA apps, UI components, static websites and MicroFrontends to S3 and Serverless Application Repository using this Lambda Layer component.
4+
5+
For more information, see [How to use CloudFormation to deploy Frontend Apps to S3 and Serverless Application Repository](https://serverless.pub/deploy-frontend-to-s3-and-sar/).

cloudformation/template.yml

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,6 @@ AWSTemplateFormatVersion: 2010-09-09
22
Transform: 'AWS::Serverless-2016-10-31'
33

44
Description: S3 Deployment Layer
5-
Parameters:
6-
DeploymentBucketName:
7-
Type: String
8-
DeploymentKey:
9-
Type: String
10-
115
Resources:
126
S3DeploymentLayer:
137
Type: AWS::Serverless::LayerVersion
@@ -16,11 +10,8 @@ Resources:
1610
- python3.6
1711
- python3.7
1812
Description: S3 Deployment Layer
19-
LayerName: !Ref AWS::StackName
2013
LicenseInfo: MIT
21-
ContentUri:
22-
Bucket: !Ref DeploymentBucketName
23-
Key: !Ref DeploymentKey
14+
ContentUri: ../build/python
2415
RetentionPolicy: Retain
2516

2617
DeploymentPermission:
@@ -33,3 +24,18 @@ Resources:
3324
Outputs:
3425
Arn:
3526
Value: !Ref S3DeploymentLayer
27+
28+
Metadata:
29+
AWS::ServerlessRepo::Application:
30+
Name: deploy-to-s3
31+
Description: >
32+
Deploy and publish Frontend SPA apps, UI components, static websites and MicroFrontends to S3
33+
and Serverless Application Repository using this Lambda Layer component
34+
Author: Aleksandar Simovic
35+
SpdxLicenseId: MIT
36+
LicenseUrl: ../LICENSE.txt
37+
ReadmeUrl: README-SAR.md
38+
Labels: ['deploy', 's3', 'lambda', 'layer', 'frontend']
39+
HomePageUrl: https://serverless.pub/deploy-frontend-to-s3-and-sar/
40+
SemanticVersion: 2.3.0
41+
SourceCodeUrl: https://github.com/serverlesspub/cloudformation-deploy-to-s3

0 commit comments

Comments
 (0)