Member-only story
Localizing content with Lambda@Edge

Recently our marketing team came to me with the challenge of localizing content for viewers from different countries on the GreenOrbit website. They explained the use case and benefits to running a multi-regional and multi-lingual website, it was all well planned out and just needed to be executed. To provide some background, the GreenOrbit website is built using a serverless architecture and powered by gatsby.
The team had already found a plugin to use with Gatsby to help build the content but they needed a “server side” method to perform a redirect to the localized content depending on what the user’s browser language was set to. All other resources such as images, css and javascript are shared. As an example of how the end solution needs to work, when a user from Australia visits the website the expected behaviour is a redirect 302 to /en-au/ to occur.

While I’ve been experimenting with Lambda@Edge in my own time recently, I’d never used it in a production ready website or app. The concept is very simple however, capture a request or response between your visitor and CloudFront or between CloudFront and your origin (where your content comes from, s3 in our case), execute some code and…