An AWS lambda for generating a sitemap.xml and storing it to S3.
- Install Node.js 4.x
- Install dependencies:
npm install
- Copy
settings.json.template
tosettings.json
in the project route
The base URL of the collections online website.
The base URL of the S3 bucket where the sitemaps are stored.
The maximum number of URLs to include in each sitemap file (50,000 is the spec max)
The size of the pages retrieved from elasticsearch.
Temporary directory where the sitemap files are stored. For running on AWS this should be set to /tmp
but recommended to be tmp
for local dev.
Connection details for the elasticsearch index to use.
AWS S3 bucket name and access credentials for where to put the sitemap files. These credentials should have permissions to write to and set permissions on the bucket.
-
Install just the dependencies needed for running the lambda
rm -rf node_modules npm install --production
-
Zip the lambda ready for upload
npm run build # (Built ZIP can be found in dist/sitemap-vX.Y.Z.zip
-
Use AWS console to create a new lambda
- Choose lambda-canary blueprint
- Name trigger and set rate to "1 day"
- Name function "sitemapGenerator"
- Runtime Node.js 4.3
- Choose Upload a .ZIP file
- Set handler to "index.handler"
- Choose Create new role from template(s)
- Set memory to "512"
- Set timeout to "5 mins"