Skip to content

Commit 3f2b664

Browse files
authored
explain the parameters
1 parent 7a65312 commit 3f2b664

File tree

1 file changed

+30
-4
lines changed

1 file changed

+30
-4
lines changed

example/template.yml

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,55 @@ Resources:
66
TargetBucket:
77
Type: AWS::S3::Bucket
88

9+
# this function is used only during deployment,
10+
# enabling cloudformation to pack up the web site source and assets
11+
# using the standard cloudformation package process
912
SiteSource:
1013
Type: AWS::Serverless::Function
1114
Properties:
1215
Layers:
16+
# the layer contains the deployment code
17+
# so the function "source" can just contain the web assets
1318
- arn:aws:lambda:us-east-1:145266761615:layer:s3-deployment:1
19+
# point to directory with the assets so cloudformation can
20+
# package and upload them
1421
CodeUri: web-site/
22+
# really important: this will ensure that any change in
23+
# the bundled files gets deployed again. we're abusing
24+
# the custom resource pipeline here, so this will be used
25+
# to change parameters of the resource and re-trigger it
1526
AutoPublishAlias: live
27+
# the following two lines are required to make the layer work
1628
Runtime: python3.6
1729
Handler: deployer.resource_handler
30+
# set the timeout to something reasonable depending on
31+
# how long it takes to upload your assets to S3
1832
Timeout: 600
33+
# give the function access to the bucket where it
34+
# will upload the assets
1935
Policies:
2036
- S3CrudPolicy:
2137
BucketName: !Ref TargetBucket
2238

39+
# This is a custom resource that
40+
# will trigger the function during deployment
2341
DeploymentResource:
2442
Type: AWS::CloudFormation::CustomResource
2543
Properties:
44+
# the following two lines are requires to
45+
# ensure that cloudformation will trigger the
46+
# resource every time you change the bundled files
2647
ServiceToken: !GetAtt SiteSource.Arn
27-
TargetBucket: !Ref TargetBucket
28-
Acl: 'private'
29-
CacheControlMaxAge: 700
3048
Version: !Ref "SiteSource.Version"
49+
# tell the deployer where to upload the files
50+
TargetBucket: !Ref TargetBucket
51+
# Choose the ACL and caching policies
52+
# eg, for directly accessible web site
53+
# use public-read and 10 minutes caching
54+
Acl: 'public-read'
55+
CacheControlMaxAge: 600
56+
3157

3258
Outputs:
3359
DestinationBucket:
34-
Value: !Ref TargetBucket
60+
Value: !Ref TargetBucket

0 commit comments

Comments
 (0)