Software Principles Explained Simply

DRY (Don’t Repeat Yourself) This principle means you should not write the same code in many places. If you need to repeat something, create a function or class and reuse it. It helps make your code easier to update and understand. KISS (Keep It Simple, Stupid) Keep your code simple. Avoid complex solutions when a simple one works. Simple code is easier to read, test, and fix later. YAGNI (You Ain’t Gonna Need It) Don’t build features that you don’t need right now. Focus on what the project needs today, not what you might need in the future. ...

AWS SAM Nested Stacks for a Structured GraphQL API

This example provides a structured approach to deploying a Serverless GraphQL API using AWS Serverless Application Model (SAM), leveraging Nested Stacks for modularity. Project Structure: Modular Stacks The core idea is to break down the infrastructure into specialized, manageable units using SAM’s Nested Stacks. This separation enhances clarity, reusability, and maintainability. The Root Template acts as the orchestrator, defining the dependencies between the smaller stacks: RolesStack (stacks/roles.yaml): Creates the necessary IAM Roles for Lambda execution and for AppSync to invoke the Lambda function. GraphQLStack (stacks/graphql.yaml): Provisions the AWS AppSync GraphQL API, including the API itself, the API Key, and the Schema definition (which is assumed to be uploaded to an S3 location). FunctionsStack (stacks/functions.yaml): Deploys the Lambda function, the AppSync Data Source, and the Resolvers query.graphql the schema definition can also be split into smaller files (types, queries, and mutations). These fragments are then merged into a single final schema file (schema.graphql). The best thing about this design is that everything is organized and independent. Each group of functions or resources is in its own box (stack). ...

Organizing Serverless Code with AWS SAM: Lambda Layers and Testing with Jest

This example demonstrates how to build clean, testable, and modular serverless applications on AWS using AWS SAM, Lambda Layers, and Jest. It focuses on two essential practices for scalable serverless development: Using Lambda Layers to share code across functions Using Jest to properly test each function and its dependencies By combining these two patterns, you get a powerful structure that’s maintainable, reusable, and confidently testable. Project Overview: Shared Logic + Layer for Node Modules + Testing functions/ – Your Lambda function handlers: ...

Understanding AWS Lambda Functions

What is AWS Lambda? AWS Lambda is a serverless computing service from Amazon. No servers to manage – AWS handles all the infrastructure. Automatic scaling – if 10,000 users call your API, AWS runs 10,000 copies of your function. Cost-efficient – you pay only for execution time, not idle time. Fast to deploy – perfect for small tasks or microservices. How does it work? Each Lambda function is triggered by an event — like an HTTP request, a file upload, or a message. When that event happens, AWS automatically runs your code. ...

Using Parameters vs. Export/Import in AWS SAM: What’s Better?

When you build serverless applications with AWS SAM or CloudFormation, sometimes you need to share resources between stacks. For example, you may have: A Cognito User Pool in one stack (for user authentication) And an API Gateway in another stack that needs to use that Cognito pool There are two main ways to connect these stacks: Option 1: Using Parameters You can pass values like the User Pool ARN or ID as a parameter when you deploy the second stack. ...