code for article pfeilbr/aws-api-gateway-to-s3-static-site-playground
WARNING: you probably shouldn’t do this / there’s a better way just because you can do it doesn’t mean you should :) was curious if it could be done
#awswishlist
private s3 bucket websites with TLS support
- example of hosting static site (create-react-app) with api gateway -> s3
- static site content at
my-react-app
Example Deployment Steps
STAGE="dev"
STACK_NAME="aws-api-gateway-to-s3-static-site-playground"
# deploy resoruces
sam deploy --guided
# build react app
pushd my-react-app
# need to set root to subpath because of api gateway stage in path limitation
PUBLIC_URL="/${STAGE}" npm run build
popd
# deploy site
aws s3 sync my-react-app/build/ s3://aws-api-gateway-to-s3-static-sit-staticsitebucket-2k3gk0lgl72u
# visit site
open https://a4kesxi0gg.execute-api.us-east-1.amazonaws.com/dev/index.html
screenshots
Resources
- API-Gateway S3 Proxy - followed this console guide to get it to work. export as openapi from console and embed in
template.yaml
- Tutorial: Create a REST API as an Amazon S3 proxy in API Gateway - Amazon API Gateway
- API Gateway S3 Integration Signature does not match with blank folder name
- Functionless S3 Integration inside a Serverless Casserole-Part 1
- SAM Template for AWS Api Gateway Integration with S3 as AWS Service
Twitter • Reddit