S4 ("S3 Search") enables quick searches on static websites hosted
with S3. Users enter their query as part of the
URL path. For example, search.example.com/code
might redirect to
example.com/pages/how-to-write-clean-code.html
. The project exists as a Lambda
behind API Gateway. This project was bootstrapped
with Chalice.
Try the project at s.penson.io! This page will search my wiki.
First, install requirements.
cd s4
virtualenv -p python3 venv
. venv/bin/activate
pip install -r requirements.txt
Then, deploy with Chalice.
chalice deploy.
View logs with Chalice.
chalice logs
Run tests with pytest
.
python -m pytest
Note that you'll need to install dependencies from tests/requirements.txt
.
This project relies on one environment variable. BUCKET
holds the name of the
S3 bucket you'd like to search. Edit this value in s4/.chalice/config.json
.
Follow the steps below to serve the search from a custom domain name. These steps assume that you have a domain registered with Route53.
- Navigate to API Gateway from the AWS console.
- Click Custom Domain Names in the sidebar.
- Select Create Custom Domain Name and enter your domain name.
- Add a Base Path Mapping with a destination of
s4:api
. - Navigate to Route53 from the AWS console.
- Click Hosted zones and select your domain name.
- Select Create Record Set and enter a subdomain (I chose
s
). - Choose
A - IPv4
as the type. - Toggle Yes under Alias and look for the API Gateway API under Alias Target.
- Lastly, click Create.