There are a lot of different efforts out there to simplify the creation of backend and middleware for mobile and web applications. The serverless movement, as the name suggests, is that this code is so minimal that you can do it in a series of stateless cloud functions using something like AWS Lambda (there are others, I can’t think of them off the top of my head). You’re just using those functions to pass data back and forth between your application and your data store, and whatever minimal business logic you need can be implemented there. Each of these functions are (in theory) so simple that you should be able to largely automate their creation, and then have some very minimal configuration to handle the edge cases.

The problem with this idea that backend is often not a simple thing. Real business logic is covered with warts and hairs. Once you go outside of the most basic requirements, you end up doing wild contortions to adapt your nice, clean serverless environment to meet them. Such a system becomes a tangle of different cloud functions that are hard to manage and maintain, and you might have been better off writing a service or a set of services that accomplished the same thing. I’m not saying the idea of serverless is bad. I’m saying I haven’t yet seen an implementation that didn’t make me sad.

AWS Amplify is one such attempt. It’s basically a tool that automates the process of cobbling together a myriad of discreet AWS products into a single application. You install it as part of your app. It comes with integrations for things like React, React Native, Flutter, Android, etc. You install a CLI, configure it with your AWS settings, answer a few setup commands and wham-bam-pow, you’ve got a working backend that uses Lambda, AppSync (GraphQL) and a host of other services to do application’s bidding, and the code is all right there in your app and you can modify and deploy it with a few commands. You can have a distributed, high-availability hello world app up in minutes. It’s truly impressive.

“Cool!” I can hear you say. “So now I just need to add auth!” No problem! With few more simple commands, your app can sign up users, verify phone/email, create accounts and wrap your app in authentication code that makes it all work.

“Nice!” you say. “Let’s add some data!” A few more commands and you’ve got a flexible data store you can access with GraphQL that’s already integrated with your auth from the previous step. So far so good!

“Wow!” you say. “This is great! Let’s use our user data with our data store so we can control who can create what and who can see what!” Well, friend, this is where the whole thing truly falls apart.

Amplify doesn’t have any easy way of connecting Cognito users to the data in your data stores. If this were a plain ol’ SQL database, this would be trivial. Using AppSync and Cognito, it’s a horrifying mess that required creating a bunch of Lambda functions and attaching them to your GraphQL logic. You now have users in two different places, in Cognito and in your datastore. They’re not coupled in any meaningful way without you wiring that up yourself, which isn’t well documented and comes with a host of gaping security issues you have to address and a bunch of synchronization headaches. Oh, you want ant a unique ID on your records? You want to enforce that said ID isn’t duplicated? You want to do a host of other seemingly trivial things? You’re on your own in a maze of disconnected and unsympathetic services.

To be fair, there are workarounds for all of these problems. Some very successful applications have been written with Amplify (most notably Parler, which while a disaster for humanity was very clever from a technical perspective). All of those workarounds, however, require an understanding of the AWS services that Amplify is supposed to wrap. If I need a series of workarounds and a deep understanding of what’s under the hood to use your system that’s supposed to automate all the tedious stuff, what’s the point? Why not just write something in Node or Go that’s self-contained, easy to maintain, and can use all of the AWS services independently?

In the end, Amplify is a nice idea, and maybe in the future it will improve, but for now, I am of the opinion that it’s not worth the trouble it’s supposed to help you avoid getting into.

← Xoth Devlog Pt. 11 React Native and Expo Actually Great →