Simplifying Cloud Application Development with Functional Web App Architecture and AWS CDK Constructs

tfc

Hatched by tfc

Oct 10, 2023

4 min read

0

Simplifying Cloud Application Development with Functional Web App Architecture and AWS CDK Constructs

Introduction:
Developing and deploying web applications on the cloud can be a complex task, involving considerations of logical and physical architecture, infrastructure reproducibility, and resource management. However, by leveraging the power of Functional Web App (FWA) architecture and AWS CDK constructs, developers can simplify the development process and achieve high availability with ease. In this article, we will explore the key concepts of FWA and AWS CDK constructs and how they can be used together to reduce complexity and enhance productivity.

Logical vs Physical Architecture:
When developing a web application, it is important to understand the distinction between logical and physical architecture. The logical architecture refers to the structure of the system's source code, while the physical architecture relates to the cloud infrastructure that runs the code. Ideally, there should be no distinction between the code we author and the code that runs. However, traditional server-centric MVC applications on the cloud often have separate logical and physical architectures. This can lead to issues with reproducibility and bug resolution. To address this, modern MVC systems have evolved to define infrastructure alongside the code. This approach, known as Infrastructure as Code (IaC), helps ensure consistency and reproducibility.

JAMstack Architecture:
One way to simplify the complexity of traditional three-tier architectures is to adopt a two-tier architecture known as JAMstack. JAMstack is a modern approach that involves pre-rendered markup for the presentation layer and browser JavaScript for business logic, with APIs acting as the server. While JAMstack offers advantages such as improved performance and scalability, it also comes with trade-offs. Dynamic data and personalization functionality may be delayed due to reliance on browser client JavaScript, and the physical architecture of JAMstack applications often lacks determinism due to reliance on third-party API providers.

Functional Web App (FWA) Architecture:
An alternative approach to simplifying cloud application development is to move up the cloud vendor stack and adopt a Functional Web App (FWA) architecture. In an FWA, the entire application is authored as single-responsibility cloud functions that can dynamically render HTML-first. The FWA incorporates the full stack, including a managed database, and the presentation and application logic are modeled in the backend using pure cloud functions. By deploying the FWA with Infrastructure as Code, developers can ensure complete reproducibility and eliminate delivery and maintenance headaches. The resulting logical and physical architectures of an FWA are identical, simplifying the development process and enhancing availability.

Leveraging AWS CDK Constructs:
The AWS Cloud Development Kit (AWS CDK) is a powerful open-source framework that allows developers to define cloud application resources using familiar programming languages. AWS CDK introduces the concept of constructs, which are the basic building blocks of CDK apps. Constructs represent "cloud components" and encapsulate all the necessary information for AWS CloudFormation to create the component. There are three levels of constructs in AWS CDK: L1, L2, and L3.

L1 constructs, also known as Cfn resources, are low-level constructs that require configuring all resource properties and a deep understanding of the underlying CloudFormation resource model.

L2 constructs offer a higher-level, intent-based API for AWS resources. They provide convenient defaults, boilerplate code, and glue logic that would otherwise need to be written manually with L1 constructs. L2 constructs simplify working with AWS resources and enhance productivity.

L3 constructs, known as patterns, are designed to complete common tasks in AWS, often involving multiple types of resources. They provide even higher levels of abstraction and further reduce the complexity of application development.

By leveraging AWS CDK constructs, developers can reduce the amount of boilerplate code, have more control over resource management, and simplify the deployment process. Starting with L2 constructs is recommended as they provide sane defaults and strike a good balance between control and convenience.

Actionable Advice:

  1. Embrace Infrastructure as Code (IaC): Use tools like AWS CDK and define your infrastructure alongside your code. This ensures reproducibility, simplifies bug resolution, and enhances collaboration among developers.

  2. Adopt Functional Web App (FWA) Architecture: Consider moving to an FWA architecture to simplify cloud application development. By modeling the presentation and application logic in the backend using cloud functions, and deploying the entire app deterministically, you can eliminate complexity and achieve high availability.

  3. Leverage AWS CDK Constructs: Take advantage of AWS CDK constructs to simplify resource management and enhance productivity. Start with L2 constructs, which provide convenient defaults and reduce the need to understand the underlying CloudFormation resource model.

Conclusion:
Developing and deploying web applications on the cloud can be complex, but with the right architecture and tools, developers can simplify the process and enhance productivity. By adopting Functional Web App (FWA) architecture and leveraging AWS CDK constructs, developers can eliminate complexity, ensure reproducibility, and achieve high availability. Embracing Infrastructure as Code, adopting FWA architecture, and leveraging AWS CDK constructs are actionable steps that can significantly improve the development experience and the quality of cloud applications.

Sources

← Back to Library

Hatch New Ideas with Glasp AI 🐣

Glasp AI allows you to hatch new ideas based on your curated content. Let's curate and create with Glasp AI :)

Start Hatching 🐣