This is not a short series; it clocks in at over 11,000 words and is a detailed tutorial on how to get a good understanding of several technologies. Many of the articles are long, and require you to actually have an AWS console screen open in front of you. This might be something best to work through when you have a bit of time. Additionally, you can contact me at
rob@<blog-domain-name>.com if you have any problems / something cool you wrote / things to chat about.
We are going to make a Twitter and email campaign ‘serverless’ backend for a site using entirely AWS cloud services (mainly Lambda and DynamoDB) to save a ton of money over classic infrastructure implementations. Again, this is a massive tutorial, so set aside a few hours to complete it. We’ll be doing everything from encryption and key management to creating a static site behind AWS Cloudfront.
What you need to install and setup to get this project to work.
Email, Lambda, Mailgun, Dynamo, S3
There is going to be a lot coming at you all at once in this post. This is a large project with a lot of moving parts; while I actually built this incrementally, we’ll just be building pretty much everything final-stage here (with a few exceptions). Take your time and read everything. We’ll be touching S3, Lambda, IAM, KMS, and DynamoDB services in this post.
Syncing The Gateway
The api gateway has two things you should know about it.
- Integration Response manipulation is a twisted nightmare when combined with regexes if you aren’t very meticulous.
- It has no built-in version control of any kind.
We are going to use it manage our lambdas. Let’s begin.
How to make a session in DynamoDB
In this section, we’re just going to save some browsing information in a session (held in DynamoDB) and redirect the user to Twitter. Once we have a callback in place, we’ll use that session data to have our user follow us. We can also use that data to message that user later (we actually have the user DM themselves, explained in the next section) with some promotional news.
Let’s Send Some Tweets With Lambda
Okay, so now is finally the point where this Twitter thing comes together. In this section, we’ll process the user’s authorization to have them follow us, as well as send them a tweet stating that they are successfully signed up!
CloudFronts and Firewalls
Why Cloudfront for an API?
I’m gonna be honest: When my boss told me to put the API on CloudFront, I thought he might have been joking. Why would you need to put an API on a distribution network? Setting it up was the hardest part of this project (no, seriously), and working with the quirks of CloudFront was a pain.
Then it became super obvious why we did it once it started working.
Piping Hot Data
We’re going to move data from Dynamo DB into our local environment. Later, we’ll be decrypting it to do cool things with it. This section is super short if you’ve been following along.
The final disclaimer
I know I’ve said it about a dozen times before, but here it is for the last time: This tutorial was built to teach you cool AWS services and give you some practical experience with them. There are many, many different ways that you could have done this, and not all of them are equally suited for all purposes. Still, this very closely resembles actual production code that I have used in a company (with their explicit permission to write this guide, of course). It works, and it’s battle-tested.