At the AWS re:Invent 2022, our very own Pawel Zubkiewicz, Master Cloud Architect at TT PSC and AWS Serverless Hero, presented “Automated testing for serverless applications” during one of the Dev Chat sessions.

AWS re:Invent Dev Chat


Pawel is a passionate expert on serverless since the very beginning of his cloud journey in 2016 and has been exploring the topic of serverless testing since the fall of 2020. During the Dev Chat Pawel shared his thoughts on the theory behind testing serverless applications in the cloud and using real AWS services of locally emulated resources.
Challenges with serverless
Testing serverless applications is challenging because testing itself has always been hard, even in the pre-cloud, monolith era. In serverless we can’t control every aspect of infrastructure, more over Lambda function code does not work without other AWS services, which makes writing tests challenging.

The evolution of testing approaches (source: link)

Read on for Pawel’s 6 key takeaways from his talk

Test Lambda privileges (IAM roles). In order to achieve the principle of least privilege, Pawel recommends writing tests that validate IAM roles. These tests are very similar to an integration test but use Lambda’s IAM Role to interact with AWS cloud; that way we may verify if it has correct privileges granted (in both ways, not too little, not too much. More importantly, on the screen there is a test that checks if a function is denied access to writing data – so a “negative” test)

  1. Automate all tests. An ineffective development workflow can be replaced with automated tests. Tests are executed locally, but they use real cloud resources.
  2. Why do you test:
  3. to have confidence that code works how we think it does
  4. to have a (fast) feedback loop after making a change in code
  5. 2.  Don’t emulate AWS locally. Many serverless programmers complain about ineffective development flow. They write code, deploy to the cloud, invoke a Lambda function (it fails), check logs in Amazon CloudWatch, then start write code again. After several iterations like this, they finally have the working code, but that takes too long. Often, developers want to emulate cloud and test locally because they are after convenience and speed. Both can be achieved when testing using real cloud resources.
  6. “Often I hear people SIMULATE the cloud because of convenience and speed, but both can be achieved when testing in the cloud.”

Use real cloud resources in tests. Instead of emulation of AWS on your local computer, you create resources in the cloud. For example, database (DynamoDB) and your integration test, executed locally connects to the DynamoDB in the cloud.
Why is emulation bad? Because it makes it hard to configure on local machine, and there is no warranty that it will work exactly the same as the real cloud.

Use an architecture style that facilitates test automation. Pawel’s favorite architecture style is hexagonal architecture, also known as ports and adapters, because it promotes the creation of loosely coupled application components and facilitates test automation. However, you may use any style you prefer as long as it makes testing easier.

Ease of use over internal complexity. Testing practice needs to be simple to use even for juniors. This doesn’t mean it was easy to define and build (it wasn’t). If it’s easy to write new tests people will do it, and benefits for the whole project/team/company outweigh the cost/time invested in building more complex structure/system underneath that enables it.
Pawel’s hope and conviction is wider adoption of serverless architecture. As serverless matures so do the practices around it as well. Years ago testing was problematic, and people used “testing issue” as an argument against using serverless. Today, severless no longer has the same testing issues.
Learn more about TTPSC’s cloud services: link

_All posts in this category

blogpost
Articles

Lesson Learned Explained: Implementing a Continuous Innovation Program in the Defense Sector

In the fast-paced aviation and defense industry, one of our clients faced a key challenge: how to accelerate the adoption of modern technologies and maintain competitiveness. The solution? Implementing a Continuous Innovation Program as the foundation of a new business model. A crucial aspect of this program was the continuous testing of state-of-the-art technologies to bring increasingly innovative products to market.

Read more
blogpost
Articles

How to leverage AWS key benefits to get real business value with Cloud Application Modernization

It's not rocket science, and it's pretty obvious that businesses need to keep up with the fast-changing digital landscape to remain competitive. Cloud application modernization is a critical strategy for updating outdated and legacy systems to leverage cloud computing benefits like those offered by Amazon Web Services(AWS). With this blog post, I decided to explore ones directly related to application modernization and the overall advantages of the cloud. Also, I will address the most common question of whether it is worth to modernize existing apps?

Read more
blogpost
Articles

Cloud Native Approach: Modernize or build cloud applications from scratch?

Everyone probably knows about applications. But how about the concept of Cloud Native? Perhaps many of you, well almost everybody, have heard something and will have an opinion. Okay, then, what are native applications and the Cloud Native Approach really? Is it worth developing new applications or upgrading existing ones to the Cloud Native model to overcome technology debt and improve legacy system?In this article, I will try to answer the above questions and show why the Cloud Native approach can be a key element in the success of any organization's digital transformation.

Read more
blogpost
Articles

How can artificial intelligence influence the vision of the future and cloud computing development?

The beginning of the year is a time of intensified summary of the past months, as well as preparation of plans for the upcoming ones. During this period, there are many more or less accurate predictions about what we can expect shortly in the multiple cloud providers offer.

Read more
blogpost
Articles

Azure Cloud Security: How to ensure the Zero Trust Model and use AI to our advantage?

Since the global popularization of remote work in recent years, IT security teams are facing ever-increasing challenges to ensure effective and secure access to organizations’ critical assets, resources, and data.Elaborate phishing attacks, through which user credentials are being exposed, allowing for lateral movement attacks or installing ransomware on mission-critical infrastructure. Zero-day vulnerabilities enable malicious actors to disrupt accessed services.

Read more
blogpost
Articles

Is the Edge a new Cloud?

Nowadays, many organizations that adopted the cloud are looking into the Edge as a natural extension for their cloud-based solutions. On the other hand, the ones at the very beginning of the Cloud journey are way more aware of the Edge and the Cloud, so they are considering the usage of both technologies at the very beginning.

Read more
blogpost
Articles

Quantum Computing: Where Schrödinger’s Cat gets cozy in the Cloud

Join me for a journey that will take us from the realm of reality as we know it to a world where a cat can be both: dead and alive, and a particle can be in two places at once. Fasten your seatbelts as we explore the fascinating world of quantum computing and its role in cloud computing.

Read more
blogpost
Articles

Will hybrid cloud and multi-cloud defend you from vendor lock-in? Do you really need to be wary of it?

Vendor lock-in is a concept overly often associated with the IT industry, and in recent years, especially with cloud computing, although it is not inextricably linked with them. Economists considered it in a broader context long before the world first heard of AWS or Azure. From a customer and user perspective, it has tended to be viewed negatively, often creating reluctance and fear of using a particular service or product.At first glance, the problem is not trivial in the public cloud area. Even the main beneficiaries of the phenomenon, i.e. the largest cloud providers, have decided to raise the issue on their official websites, so clearly something must be...And whether it actually is, we will check in this article. We'll look at the risks of vendor lock-in for organizations planning cloud adoption. We'll also consider whether using multiple vendors (multi-cloud ) simultaneously can be a good recipe for improvement. In addition, we will take a look at the hybrid cloud.

Read more
blogpost
Articles

The critical role of cloud-based data platforms. Reshaping manufacturing data management

Cloud-based data platforms revolutionize manufacturing data management by efficiently handling vast amounts of data in real-time. Manufacturers can collect data from various processes, analyze it with advanced tools like AI/ML algorithms and BI, and make informed decisions. These platforms offer key benefits, vital elements, and integration with Data Strategy.

Read more
blogpost
Articles

How can AI Data Discovery help manufacturing companies?

We are all blessed to live in very exciting times. Exponential technological progress over the last couple of decades has influenced not only our personal lives but also heavily impacted business. Trends are obviously evolving occasionally, but it is safe to say that now is the time of advanced analytics.

Read more

Let’s get in touch

Contact us