A technique to separate business logic in your code.

Photo by Ludemeula Fernandes on Unsplash

Lambda functions should only do one thing at a time. Mixing business logic is never good in the long term: testing and maintainability can become a pain.

One way to separate business logic into multiple Lambda functions is by using the many event sources that AWS provides to start a Lambda function invocation.

💁 I previously wrote a little introduction to event-driven architectures using AWS and Terraform.

AWS Lambda has a nice feature when it is invoked asynchronously: attaching destinations to your Lambda invocation. After the Lambda function finishes its execution it sends the response to the configured destination. These…


An opinion on how many LOC or commit frequency in a PR

Photo by Caleb Woods on Unsplash

I’m in charge of a small team of developers, six including myself. I’m the team lead so I have several responsibilities besides just coding. Some of these are:

  • Planning ahead for new features.
  • Resource allocation.
  • Guiding my team when they have questions about a Github issue or something on the codebase.
  • Mentoring so they can have a better understanding of their career paths.
  • Reviewing PRs.

I consider PRs the best source of knowledge to understand your team’s code skills and quirks, especially since COVID where everything runs remotely. There is only so much you can get from Slack messages or…


From project structure to build your Lambda to deploying in AWS

Photo by Paul Hanaoka on Unsplash

Lately I’ve been working with Go. Coming from Javascript it has been a journey to change the mindset in order to code with Go. I’m not going to talk about the pros vs cons of using Go with Lambdas or as a programming language. What I would say is that if you want to try something new, Go is a very accessible programming language to learn, and the performance inside a Lambda function is incredible.

Also if your project relies on threads Go has got you covered.

Assuming you have some basic knowledge of Go, let’s dive into how to…


Serverless Framework and Terraform to the rescue

Photo by A Cruikshank on Unsplash

When building applications we strive for automation that runs faster so developers can see their changes as soon as possible. Using AWS Lambda is a way for developers to focus more on business logic and less on how to tinker with a server.

A limitation of AWS Lambda is the size of the deployment package, currently capped at 50MB zipped. This could be an issue if developers are installing packages to make their code work, which is where Lambda layers come to the rescue.

A Lambda layer is a .zip file archive that can contain additional code or data. A…


Simple example using AWS and Terraform.

Photo by Sereja Ris on Unsplash

When designing software there are many architecture patterns that we can choose from. We have the monolithic applications everyone is trying to run away from, and the microservices everyone is running towards. I want to talk about event-driven architecture.

Event-driven architectures react to changes on the state of your application.

To illustrate this let’s make a simple application. The purpose of the application is to upload a CSV file of names and emails and mock the process of bulk creating user accounts. After inserting each user, we send them a welcome email.

Some things to do first. If your SES is in Sandbox mode you should verify at least one email…


How a small change can increase your app performance

TL;DR: Read the documentation

Photo by Ariana Suárez on Unsplash

I consider myself an “experienced” software engineer but almost every day I realize that learning never stops. My last ohhhh moment was about how to optimize re-renders on a React app. I have used React’s memo higher-order component before but never to its full potential. Then I discovered the second argument.

Yes, the second argument.

I don’t know how I have missed this little piece of information for so long but knowing about it can make your app faster when your components are getting heavy and rendering many elements. I’m not gonna lie, I should read more documentation in general.


How I launched Transcribe Ninja with zero money.

TL;DR https://aws.amazon.com/activate/founders/

Photo by Catherine Heath on Unsplash

Every day millions of people come up with ideas about automating something at work or how to find the “Answer to the Ultimate Question of Life, the Universe, and Everything”. Then realizing that this idea can help other people, they build a prototype to test it.

The problem comes when they don’t know if the idea would actually work, and to know they need to spend money. That money can come from asking their friends, acquiring their first customers or going the VC route.

Another way to bootstrap their idea is by…


Easy way to access secrets like API keys in AWS Lambda

Photo by Manja Vitolic on Unsplash

When developing functions with Lambda you will have cases when you need to access an external third-party application (e.g. Stripe). To do this you will most likely need an API key provided by the external service.

The first instinct is to save this API key as an environment variable. See the code in Terraform:

resource "aws_lambda_function" "test" {  
filename = "test.zip"
function_name = "test"
handler = "test.handler"
source_code_hash = filebase64sha256("test.zip")
runtime = "nodejs12.x"
environment {
variables = {
API_KEY = "api-key"
}
}
}

Although this is fine for a quick implementation, it is not 100% secure since the API…


TL;DR Return status code 200 on your GraphQL calls.

Photo by Ramiz Dedaković on Unsplash

If you are developing a GraphQL API without using AppSync like me, you are probably using API Gateway + Lambda to build your GraphQL endpoint.

On the frontend you may be using React along with Amplify.

You have been writing your schemas and building your queries/mutations on the backend; coding some UIs on the frontend. Then you think that you should handle errors from GraphQL, so if one occurs you can show a nice error message and avoid the users’ frustration.

You think you are clever and write this for your GraphQL endpoint:

export const handler = async event =>…


Using queues with Lambda

Photo by Anton Darius on Unsplash

When building event-driven applications it’s common to process objects that are uploaded to an S3 bucket. There are several ways to listen to S3 events using S3 notifications. You could directly call a lambda function after every upload or send the notification an to SNS topic/SQS queue as an intermediary between the two.

For a high-performance and scalable solution that handles errors, SQS is the best option.

Lambda has a limit of 1000 concurrent invocations per second.

SNS doesn’t guarantee that every notification will be delivered only once.

If the delivery throws an error, SQS lets…

Jose Antonio Gonzalez Rodriguez

Lead Software Engineer @ Virtual Academies

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store