AWS API Gateway to S3 Static Site

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