RSSAmplifier

Blog

Better Dev

Serverless on AWS

betterdev.blogRSS feed ↗37 posts

Latest posts

Should you minify Lambda code?

I thought minimizing Lambda function code was a best practice for Lambda optimization - it's even recommended by AWS in a not-so-old blog post . Turns out, I was wrong .

Next-Level Integration Testing with ServerlessSpy

Integration testing for serverless Event-Driven Architecture is as necessary as it is time-consuming. Boilerplate code to write, long waiting for tests completion, tedious debugging. But no more.

25 Good and Bad Serverless (and other) Announcements from re:Invent 2023

AWS re:Invent 2023 ended, so let's look at the most interesting announcements for serverless and more. There are exciting features to try and, maybe more importantly, features to avoid !

Dynamic Content with Lambda Response Streaming

With some creativity, we can use Lambda Response Streaming to dynamically show status updates , like the progress of long-running processes. And with proper TypeScript types and generator functions , we can write clean, dynamic content streaming Lambda with composable payload enrichers that will impress your work colleagues (if they are into this stuff).

Forcing Lambda Response Streaming to Flush Content

Lambda Response Streaming allows sending incremental responses, but those response chunks can arrive long after you write them. They are buffered in a rather unexpected way, delaying all messages you stream. But there is a workaround to force the stream to flush.

Building a CDK Construct Library: thoughts and tips

I recently created a CDK library provisioning a CI/CD pipeline for serverless apps on AWS . Having finished the "regular" JS library, it took me a day to convert it to a "proper" CDK Construct library. Not long, and I learned a lot. Here are my thoughts and tips.

AWS Lambda - Node.js vs. Python for serverless

After tabs vs. spaces, vi vs. emacs, let's fight over this: which is better, Node.js or Python for AWS Lambda and serverless in general? I have my opinion on this, and the fact I prefer TypeScript over Python makes me only slightly biased.

Understanding Logical IDs in CDK and CloudFormation

CDK generates Logical IDs used by the CloudFormation to track and identify resources. In this post, I'll explain what Logical IDs are, how they're generated, and why they're important. Understanding this will help you avoid unexpected resource deletions and baffling "resource already exists" errors during deployment.

Top 12 Serverless Announcements from re:Invent 2022

re:Invent 2022, the annual AWS conference in Las Vegas, is now behind us. I did not attend in person, but that gave me time to consolidate this list of top new serverless features while everyone else is sleeping off the intense 5-day conference. And I envy them just a little.

How to pass AWS Certification exams

I've never cared too much about certificates, apart from the SSL ones (haha). And yet I passed 7 AWS exams. Why? How to prepare? How to pass? How to pay only 50% for the exam? I answer all this and more in this post.

Running Serverless ML on AWS Lambda

Yes, you can run Machine Learning models on serverless, directly with AWS Lambda. I know because I built and productionized such solutions. It's not complicated, but there are a few things to be aware of. I explain them in this in-depth tutorial, where we build a serverless ML pipeline.

Least deployment privilege with CDK Bootstrap

Security is not convenient. That's probably why the CDK, by default, uses AdministratorAccess Policy to deploy resources. But we can easily change it and increase the security of our AWS account, following the least privilege principle with a minimal additional burden.

The AWS CDK, Or Why I Stopped Being a CDK Skeptic

Until recently, I was skeptical about the AWS CDK. I believe in Infrastructure as Code (IaC), but with the "code" being YAML. But after using CDK in real projects, the amount of heavy lifting it does and the vast reduction of a boilerplate code changed my view.

Things I Found Interesting #5

After some time, I accumulated enough articles to share. They are about cloud, tech, programming, and work, and also include two games, a petition, and a survey.

Decision Tree: choose the right AWS messaging service

Have you ever been stuck deciding between SQS, SNS, Kinesis Streams, and EventBridge? Struggled to pick the right one for your use case? If the answer is "yes", I've got you covered with a simple decision tree to help you make the right decision.

Personal backup to Amazon S3 - cheap and easy

In need to backup my personal files in the cloud, I wrote a script that archives the data into the Amazon S3 bucket. After some fine-tuning and solving a bunch of edge-cases, it's limited mainly by the disk read and my internet upload speed. And it costs me only $3.70 per TiB per month.

6 Common Pitfalls of AWS Lambda with Kinesis Trigger

The simplicity of setting up a Kinesis trigger for a Lambda function may be deceptive. There are pitfalls that can cause problems we will spot only later, in the production environment. I learned about some of them the hard way, so let's say I speak from the experience.

Things I Found Interesting #4

Two articles about the Blockchain on today's list. Both are not in favor, I'm afraid. Apart from this, some tools, work thoughts and advice, and again an article so weird I couldn't categorize it.

Headless CMS with Gatsby on AWS for $0.00 per month

Can you have a website with a CMS on AWS and not pay just for its existence? I looked at Amazon Lightsail, headless WordPress, and Webiny CMS but found none of those suitable . So I choose Prismic – a SaaS headless CMS, and Gatsby to create the site. Yes, I needed to make a pipeline to build my website after content changes. But when I did it, I got a website with CMS hosted at no cost .

Choosing between SQS, SNS, Kinesis, and EventBridge

AWS can overwhelm with the number of services. Especially if multiple services seem to do a very similar job. Let's look at the cloud-native AWS messaging services – the SQS, SNS, Kinesis, and EventBridge. What are the differences and when to use which one?

Things I Found Interesting #3

Here we are again , with selected content from all over the internet about tools, tech, cloud, programming, work, and a single article I couldn't categorize. Probably because I'm still in shock after reading it.

Don't help others (immediately)

I know my coworkers and teammates are reading this, and probably my boss as well. But let's risk it.

AWS Lambda Performance Optimization

There are two reasons to optimize AWS Lambda functions performance. First is money – you pay for the Lambda execution duration. The quicker you do the job, the less you pay. The second is latency – the quicker you do the job, the shorter your client waits for the result. It's a known fact that the decrease of latency improves sales, user engagement, and client satisfaction – so we could argue it's…

Things I Found Interesting #2

Two months after the previous edition , I gathered enough interesting resources to share them. In this edition, you will find content about HTTP, WebDev, versioning, tech, and problem solving.

AWS JavaScript SDK v3 - usage, problems, testing

The new version of AWS SDK for JavaScript / TypeScript / Node.js came with a few significant improvements. But does "General Availability" mean "ready for the production"? How to use it? And how to unit test our code using it? Let's take a look at it.

AWS Lambda logging best practices

Logging in AWS Lambda functions is simple. You just print the message, and it's sent to the CloudWatch Logs. And everything is fine until you get a surprisingly big bill for the CloudWatch usage, or you need to actually debug some live system. Here are my tips for logging in AWS Lambda, based on my experience with real-live, big-scale functions running on production.

Things I Found Interesting #1

Welcome to the first issue of Things I Found Interesting – an irregular series of links to, well, interesting content. Below are eleven articles and resources on various software-related topics, which I stumbled upon in the last several weeks.

Pin exact dependency versions

Buckle up, for some of you this may be controversial, but maybe for some others – obvious. This is how to prevent a problem causing your application to out of the sudden stop behaving correctly, or, even more funny, stop behaving correctly only on one developer's computer. We can solve this with one two simple tricks.

Three ways to create Amazon Athena tables

Here I show three ways to create Amazon Athena tables. More importantly, I show when to use which one (and when don't) depending on the case, with comparison and tips, and a sample data flow architecture implementation. Also, I have a short rant over redundant AWS Glue features. All in a single article. Enjoy.

Minimal safe Bash script template

Bash scripts. Almost anyone needs to write one sooner or later. Almost no one says "yeah, I love writing them". And that's why almost everyone is putting low attention while writing them.

Auto-generated website environment parameters

There are multiple articles on how to host a static website or Single Page Application (SPA) on AWS. But they rarely go into the topic of setting up the environment variables for the frontend application.

My AWS toolbox - tools, plugins and applications

Developers, like all specialists, discover and collect their favorite tools over time. Having a good, proven set of tools makes the work easier and more pleasant. We can focus on getting the job done. Sometimes eliminating minor inconveniences or improving a small element of everyday activity makes the greatest impact on the comfort of work.

Serverless Swagger UI for API Gateway

Amazon API Gateway provides an option to export the API schema as an OpenAPI Specification. With it, we can display our REST API as an interactive website. But we do not get a public URL to that specification file which we could use as a source for an interactive page like Swagger. Instead, we can only get the file from the AWS Console, CLI, or SDK.

Command line arguments anatomy explained with examples

Many of the scripts and executables allow providing some command line arguments. They may be required or optional. There are flags, that are just switches changing command behavior. There are, of course, arguments with values. And there are so-called positional arguments – parameters given in some order without any extra indications.

Speed up everyday work with handy Git aliases

Git allows us to define aliases , which are basically our own commands we can use. They may be just a calls for other commands with parameters, or even shell scripts. Possibilities are unlimited.

Simpler Git branch first push with no more errors

How many times did you try to make git push for a newly created branch to the remote repository, only to get a strange "no upstream branch" error? Here I will show how to change Git configuration with a single command to get rid of it for good.

Git fast-forward merge - why you should turn it off

Git is a standard version control tool. You should definitely use it even for small personal projects. And when it comes to any teamwork, it's mandatory.