File tree Expand file tree Collapse file tree 2 files changed +50
-0
lines changed
Expand file tree Collapse file tree 2 files changed +50
-0
lines changed Original file line number Diff line number Diff line change 1+ name : Create PR Preview
2+
3+ on :
4+ pull_request :
5+ types : [opened, synchronize, reopened]
6+
7+ jobs :
8+ test :
9+ runs-on : ubuntu-latest
10+ timeout-minutes : 15
11+ steps :
12+ - name : Checkout
13+ uses : actions/checkout@v4
14+
15+ - name : Deploy Preview
16+ uses : LocalStack/setup-localstack/preview@main
17+ with :
18+ github-token : ${{ secrets.GITHUB_TOKEN }}
19+ localstack-api-key : ${{ secrets.LOCALSTACK_API_KEY }}
20+ preview-cmd : |
21+ make build
22+ make bootstrap
23+ make deploy
24+ make prepare-frontend-local
25+ make build-frontend
26+ make bootstrap-frontend
27+ make deploy-frontend
28+ distributionId=$(awslocal cloudfront list-distributions | jq -r '.DistributionList.Items[0].Id')
29+ echo "Open URL: $AWS_ENDPOINT_URL/cloudfront/$AWS_DEFAULT_REGION/$distributionId/"
Original file line number Diff line number Diff line change 44 CfnOutput ,
55 aws_s3 as s3 ,
66 aws_s3_deployment ,
7+ aws_cloudfront as cloudfront ,
8+ aws_cloudfront_origins as origins ,
79} from "aws-cdk-lib" ;
810import { Construct } from "constructs" ;
911
@@ -22,6 +24,25 @@ export class AwsSdkJsNotesAppFrontendStack extends Stack {
2224 destinationBucket : websiteBucket ,
2325 } ) ;
2426
27+ new cloudfront . Distribution ( this , "WebsiteDistribution" , {
28+ defaultRootObject : "index.html" ,
29+ defaultBehavior : {
30+ origin : new origins . S3Origin ( websiteBucket ) ,
31+ } ,
32+ errorResponses : [
33+ {
34+ httpStatus : 403 ,
35+ responseHttpStatus : 200 ,
36+ responsePagePath : "/index.html" ,
37+ } ,
38+ {
39+ httpStatus : 404 ,
40+ responseHttpStatus : 200 ,
41+ responsePagePath : "/index.html" ,
42+ } ,
43+ ] ,
44+ } ) ;
45+
2546 new CfnOutput ( this , "FrontendBucketWebsite" , {
2647 value : `http://${ websiteBucket . bucketName } .s3-website.localhost.localstack.cloud:4566/` ,
2748 } ) ;
You can’t perform that action at this time.
0 commit comments