Home > AWS, Cloud, re:Invent, Serverless > AWS re:Invent 2017: Build a Multi-Region Serverless Application for Resilience and High Availability Workshop

AWS re:Invent 2017: Build a Multi-Region Serverless Application for Resilience and High Availability Workshop

Steven Challis & Derek Felska from AWS were the workshop leaders and it was very hands on, basically up to you and anyone else you wanted to team up with.

2017-11-27 12.58.36 2017-11-27 12.58.45

This is one of the reasons to actually attend a conference, you get to do things in person and interact with other people rather than watching a recorded session or just follow a step by step plan when you can’t confer.


Availability and fast performance is key to user experience. Building a global application from the start is traditionally extremely difficult. Think before serverless how you would have to manage a global fleet of EC2 instances, load balancers, databases and storage. You would need to be a DNS guru and keeping your compute generic yet regionalised was super tough. Enter serverless and the promise was there but Lambda needed a whole lot of hacking to get functions to fire based on geographical access.

2017-11-27 13.15.14 2017-11-27 13.05.29

In the workshop we set up a fictional company called www.wildrydes.com (would you use a ride sharing company called this!). This wasn’t just a normal rider sharing company though, the drivers were unicorns! They needed a customer support application which customers can use to report any issues, be it lost property or a grumpy unicorn! As the service was global and needed to be built, serverless was touted as the ideal platform to use as much as possible (of course, it’s re:Invent!). We needed to lash together Lambda, API Gateway, DynamoDB, Route 53, CloudFront and S3 for better availability. Cognito Federated Identities was also used for user authentication.

The workshop was also to highlight the new “API Gateway regional endpoints” feature which was recently released.

There’s no reason to feel left out though, you can go through it all at: https://github.com/awslabs/aws-serverless-workshops/

We went through an introduction into what the workshop would entail and some info on the larger availability picture, not just for the part of your app that runs but from a platform perspective. If a region fails and all your source code or build templates vanish, you may not be able to rebuild your app in another region. So, also think about replicating code (CodeCommit regional replication), data (DynamoDB Streams) and templates (CloudFormation backups).

The idea was to create a globally load balanced back-end between two regions. We didn’t concentrate on the front end as this is other functionality. DynamoDB streams was used for replicating the comments table via Lamdba from one region to another

Route53 Deep Ping will be used for end to end monitoring from API Gateway to DynamoDB

AWS SAM is an extension to CloudFormation made just for serverless, it allows package, deploy and the cool SAM local part to test functions locally with Docker.

They mentioned some other things to think of when designing globally distributed systems, you need to be aware of compliance for data sovereignty as you may be prevented legally from copying various things around the world even if it is easy technically.

Getting hands dirty

We went ahead and manually set up a single region in Ireland with some IAM policies and roles, Lambda functions to get and put stuff, a DynamoDB table and a Lambda function to replicate it and then set up the API gateway, such a powerful feature!

We then used a CloudFormation template to set up some of the UI portion which will be the interface to the API Gateway.

Onto creating a Facebook developer account and linking it to Cognito for authentication and also building a Node.js app, for this part I was into clicky-clicky-follow mode and then failed because I was on Windows so no sympathy from the rest of Mac the table. I coudn’t get the Node part to play nicely. I then landed up deploying a Demo EC2 AMI which AWS has made with a bunch of stuff installed and some good instructions to get going with a Linux option. The node part involved building a Node application, packaging it up and uploading to S3 which hosted the web site.

Then onto the secondary region which was to be in Singapore. We had some CloudFormation templates to use for this as we had done the Ireland region manually so it was a repeat.

I then also came unstuck with the custom domain portion as my custom domain didn’t have email verification properly setup which is required to create the certificate and well, it would take too long to sort this out so unfortunately I had to bumble on.

We then went through setting up the DNS aliases to point to the API Gateway ends points in Ireland and Singapore and set up the end to end monitoring.

At this stage I was putting in as much as I could but without the valid certificate things were falling apart but at least the idea of what we were trying to do was getting in. Some more code editing to now reference the DNS alias, which needed to be repackaged, built and uplaoded to S3.

Time to then deliberately break stuff to check it failed over automatically and the back end components ran out of Singapore when Ireland had an issue. Mine was broken already but I managed to see someone’s who did work.

In the end

This was a great, very hands on workshop. We managed to do a LOT of stuff in the 2.5 hour. Custom domain DNS + certificates with an API Gateway firing off Lambda functions based on whatever region targeting to read and write from a database and then getting that database replicated globally.

Although a complicated set of interacting components it really shows the power of the AWS services and how easily they can be tied together importantly without doing anything with EC2 or touching an OS or even container. OK, I say easily but there is a learning curve to understand the components but the console and CLI make at least the setup consistent and that’s the power of a true cloud.

When I have a chance I hope to continue and get it working. It was  a great learning workshop.

  1. No comments yet.
  1. No trackbacks yet.

Time limit is exhausted. Please reload the CAPTCHA.