Skip to content

Commit e40598b

Browse files
committed
cloudfront step
1 parent 1db5982 commit e40598b

File tree

3 files changed

+61
-2
lines changed

3 files changed

+61
-2
lines changed

.github/workflows/preview_create.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,5 @@ jobs:
4242
# Add your custom deployment commands here.
4343
# Below is an example for the Image resizer application.
4444
bin/build_lambdas.sh && deployment/awslocal/deploy.sh
45+
distributionId=$(awslocal cloudfront list-distributions | jq -r '.DistributionList.Items[0].Id');
46+
echo LS_PREVIEW_URL=$AWS_ENDPOINT_URL/cloudfront/$distributionId/ >> $GITHUB_ENV;

bin/distribution-config.json

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
{
2+
"CallerReference": "7809088",
3+
"Comment": "Serverless Image Resizer App",
4+
"Origins": {
5+
"Quantity": 1,
6+
"Items": [
7+
{
8+
"Id": "serverless-image-resizer-app",
9+
"DomainName": "webapp.s3-website.localhost.localstack.cloud:4566",
10+
"OriginPath": "",
11+
"CustomHeaders": {
12+
"Quantity": 0
13+
},
14+
"S3OriginConfig": {
15+
"OriginAccessIdentity": ""
16+
}
17+
}
18+
]
19+
},
20+
"DefaultCacheBehavior": {
21+
"TargetOriginId": "serverless-image-resizer-app",
22+
"ViewerProtocolPolicy": "allow-all",
23+
"TrustedSigners": {
24+
"Enabled": false,
25+
"Quantity": 0
26+
},
27+
"AllowedMethods": {
28+
"Quantity": 2,
29+
"Items": ["HEAD", "GET"],
30+
"CachedMethods": {
31+
"Quantity": 2,
32+
"Items": ["HEAD", "GET"]
33+
}
34+
},
35+
"ForwardedValues": {
36+
"QueryString": true,
37+
"Cookies": {
38+
"Forward": "none"
39+
},
40+
"Headers": {
41+
"Quantity": 0
42+
},
43+
"QueryStringCacheKeys": {
44+
"Quantity": 0
45+
}
46+
},
47+
"MinTTL": 0,
48+
"DefaultTTL": 86400,
49+
"MaxTTL": 31536000
50+
},
51+
"Enabled": true,
52+
"PriceClass": "PriceClass_All",
53+
"ViewerCertificate": {
54+
"CloudFrontDefaultCertificate": true
55+
}
56+
}

deployment/awslocal/deploy.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,5 +71,6 @@ awslocal lambda list-function-url-configs --function-name presign --output json
7171
echo "Fetching function URL for 'list' Lambda..."
7272
awslocal lambda list-function-url-configs --function-name list --output json | jq -r '.FunctionUrlConfigs[0].FunctionUrl'
7373

74-
echo "Now open the Web app under https://webapp.s3-website.localhost.localstack.cloud:4566/"
75-
echo "and paste the function URLs above (make sure to use https:// as protocol)"
74+
DISTRIBUTION=$(awslocal cloudfront create-distribution --distribution-config file://bin/distribution-config.json)
75+
DISTRIBUTION_ID=$(echo "$DISTRIBUTION" | jq -r '.Distribution.Id')
76+
echo "Distribution created with URL: http://localhost:4566/cloudfront/$DISTRIBUTION_ID/"

0 commit comments

Comments
 (0)