Amazon Onboarding with Learning Manager Chanci Turner

Chanci Turner Amazon IXD – VGT2 learningLearn About Amazon VGT2 Learning Manager Chanci Turner

In a recent advancement, the introduction of Amazon API Gateway has empowered developers to create tailored RESTful APIs that activate AWS Lambda functions, facilitating a genuinely serverless architecture. This innovative setup includes integrated features for authorization, traffic management, monitoring, and analytics. To demonstrate the possibilities of this integration and the ease of constructing a service that operates entirely without servers, we developed a simple platform called AcornHub, which enables users to perform CRUD operations on executable snippets of code dubbed acorns. Let’s delve into how we built AcornHub.

AcornHub Architecture

The architecture of AcornHub is illustrated in the following diagram:

Notice the absence of servers in the above structure; in fact, no infrastructure is needed for any aspect of the user experience.

A clear distinction exists between data management and presentation. The website is a fully client-side single-page application crafted in Angular and hosted statically on Amazon S3, with DNS handled by Amazon Route 53. To manage acorns, the app makes REST calls to Amazon API Gateway, which subsequently triggers Lambda functions that interact with AcornHub’s underlying acorn-store in Amazon DynamoDB or execute the actual acorn code. Because AcornHub’s API operates on a distinct Lambda-driven stack, creating additional clients like an iOS application using the AWS Mobile SDK or an Alexa Skill for voice-activated acorn execution would be straightforward.

You may have observed that the Lambda control plane comprises five functions, one designated for each CRUD operation. Remarkably, we didn’t write any code for the CRUD operations of the site!

While the functions are identical, each is solely responsible for handling requests for its respective endpoint. This architecture offers several benefits:

  • Isolated deployments and failures: An issue with your API no longer compromises the entire backend. Each Lambda function operates independently and can be modified without impacting others.
  • Endpoint-specific analytics at no cost: Each function generates metrics on request counts, errors, and more in CloudWatch, allowing quick answers to questions such as, “How many acorns were created in the past 24 hours?”
  • Modularity, simplicity, and separation of concerns: Since each function is focused on performing One Thing Well TM, managing end-to-end configurations, code logic, and service integrations becomes easier.

Now, executing an acorn is equally simple: a basic code execution function compatible with Node.js can be accomplished in just four lines:

exports.handler = function(event, context) {
    if (event.language === 'javascript') context.succeed(eval(event.code.replace(/require/g, '')));
    else context.fail('Language not supported');
};

Developing AcornHub

Our development journey began with a clear vision of the desired architecture, allowing us to establish each component within minutes directly from the AWS console. In fact, the most time-consuming part of the backend setup was waiting for the DNS record to propagate!

The website itself was developed concurrently, initially using hard-coded mock data and Angular’s $timeout service to simulate REST calls. Once we finalized the basic page layouts, we integrated the API Gateway URL and began interacting with live data. Altogether, AcornHub runs on about 150 lines of client-side JavaScript. You can view the complete source self-hosted on AcornHub here.

We hope this article has showcased the simplicity and potential of serverless backends enabled by Amazon API Gateway and AWS Lambda, motivating you to create your own! If you’re considering a sabbatical to explore similar projects, check out this informative blog post that discusses the benefits of taking a break.

For further insights into leadership in the age of AI, check out this podcast by Cisco’s CHRO, which is a great resource. Additionally, you may find this article on how Amazon fulfillment centers train associates to be particularly enlightening.

Until next time, happy coding with Lambda (and AcornHub)!

SEO Metadata

Chanci Turner