Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Mastering AWS Lambda
Mastering AWS Lambda

Mastering AWS Lambda: Learn how to build and deploy serverless applications

Arrow left icon
Profile Icon Yohan Wadia Profile Icon Gupta
Arrow right icon
€18.99 per month
Full star icon Full star icon Empty star icon Empty star icon Empty star icon 2 (1 Ratings)
Paperback Aug 2017 300 pages 1st Edition
eBook
€8.99 €29.99
Paperback
€36.99
Subscription
Free Trial
Renews at €18.99p/m
Arrow left icon
Profile Icon Yohan Wadia Profile Icon Gupta
Arrow right icon
€18.99 per month
Full star icon Full star icon Empty star icon Empty star icon Empty star icon 2 (1 Ratings)
Paperback Aug 2017 300 pages 1st Edition
eBook
€8.99 €29.99
Paperback
€36.99
Subscription
Free Trial
Renews at €18.99p/m
eBook
€8.99 €29.99
Paperback
€36.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing
Table of content icon View table of contents Preview book icon Preview Book

Mastering AWS Lambda

Writing Lambda Functions

In the previous chapter, we understood serverless computing and took a quick look at how easy it is to get started with AWS Lambda functions using the AWS Management Console, as well as with the AWS CLI.

In this chapter, we are going to take things a step further by learning the anatomy of a typical Lambda function, and also how to actually write your own functions. The following topics are covered in this chapter:

  • Understanding the programming model for a Lambda function using simple functions as examples
  • Working with environment variables and versioning
  • Leveraging third-party tools for a quick and effortless code deployment to Lambda

So no more talking, let's get coding!

The Lambda programming model

So far we have seen that certain applications can be broken down into one or more simple nuggets of code called as functions and uploaded to AWS Lambda for execution. Lambda then takes care of provisioning the necessary resources to run your function along with other management activities such as auto-scaling of your functions, their availability, and so on. So what exactly are we supposed to do in all this? A developer basically has three tasks to perform when it comes to working with Lambda--writing the code, packaging it for deployment, and finally monitoring its execution and fine-tuning.

In this section, we are going to explore the different components that actually make up a Lambda function by understanding what AWS calls as a programming model or a programming pattern. Currently, AWS officially supports Node.js, Java, Python, and C# as the programming...

Versioning and aliases

In the real world, we often have different environments to work out of, for example development, QA, staging, pre-production, production, and so on. Having to manage a single Lambda function across all these environments can be a real pain, and also tricky especially, when each of your environments provide different configuration options, such as different connection strings for databases hosted for development and production, different roles and resource settings.

Lambda thus provides few add-on services that help you better categorize, and manage functions in the form of versions and aliases.

Versioning is a simple way to create one or more versions of your working Lambda code. Each version that you create is basically a snapshot of your origin function. Versions are also immutable which means, that each version you create from the origin or [$LATEST]...

Packaging and deploying

We touched on the concept of packaging and deploying a simple Lambda function earlier in Chapter 1, Introducing AWS Lambda and parts of it in this chapter as well, however in this section, we will be doing things a bit differently! Rather than covering the steps all over again, we will be exploring a few simple and powerful open source Lambda deployment tools that are currently out there in the market today! Why tools you ask? Well, why not?

As a developer we always want to make the deployment and management of our codes simpler and hassle free, especially when it comes to working with a lot of Lambda projects at the same time. These tools accelerate time to development and also help us reduce any errors that may occur when working with the AWS Management Console or the AWS CLI. In this section we will be exploring two such tools that are gaining a lot...

Recommendations and best practices

Following is a list of some of the recommendations and best practices to follow:

  • Optimize your code: Writing syntactically correct Lambda functions is one thing and writing optimized functions is totally another. For example, it's always a good practice to initialize any external services like DynamoDB, SNS outside your function code. The reason for this is simple, each time Lambda starts your code, the underlying container starts up. At this point, the code outside the handler runs first (initialization). When subsequent function calls are invoked, Lambda reuses the same container to run your functions and as a result you save resources and time by not instantiating the external services again.
  • Versioning and aliases: As discussed before, versioning and aliases are a very important set of tools that you should leverage when creating and...

Planning your next steps

With the chapter almost at the end, here are few key next steps that I feel are worth trying out before we jump over to the next chapter. Firstly, create your own Lambda functions and deploy them either by using APEX or Claudia.js. This will help you in understanding versioning and aliases a bit better along with added simplicity to deploying functions as we move along this book. Additionally, there are other deployment tools and services present out there such as lambda-tools, gordon, and serverless which we will be covering in the later chapters.

Next, with the programming model in mind, try out developing the Lambda functions with Java and Python as well. In fact, you can use APEX to deploy your functions with golang as well. You can read more about the steps here at https://www.wolfe.id.au/2016/08/13/bootstrap-an-apex-golang-project/. More importantly...

Summary

It has been a long yet awesome chapter to learn. So let us summarize what we have learnt so far. First up, we deep dived into the Lambda programming model and understood each of its sub components (handlers, context objects, errors and exceptions) with easy to follow examples. Next, we covered how to effectively write and develop functions using the concepts of versioning and aliases. Finally, we concluded the chapter by understanding the use of environment variables and also looked at a few essentials recommendations and best practices to keep in mind when writing Lambda functions.

In the next chapter we will be learning about the importance of testing your code along with some really useful testing tools and frameworks. So stick around, we are just starting out!

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • ? Leverage AWS Lambda to significantly lower your infrastructure costs and deploy out massively scalable, event-driven systems and applications
  • ? Learn how to design and build Lambda functions using real-world examples and implementation scenarios
  • ? Explore the Serverless ecosystem with a variety of toolsets and AWS services including DynamoDB, API Gateway, and much more!

Description

AWS is recognized as one of the biggest market leaders for cloud computing and why not? It has evolved a lot since the time it started out by providing just basic services such as EC2 and S3 and today; they go all the way from IoT to Machine Learning, Image recognition, Chatbot Frameworks, and much more! One of those recent services that is also gaining a lot of traction is AWS Lambda! Although seemingly simple and easy to use, Lambda is a highly effective and scalable compute service that provides developers with a powerful platform to design and develop Serverless event-driven systems and applications. The book begins with a high-level introduction into the world of Serverless computing and its advantages and use cases, followed by a deep dive into AWS Lambda! You’ll learn what services AWS Lambda provides to developers; how to design, write, and test Lambda functions; as well as monitor and troubleshoot them. The book is designed and accompanied with a vast variety of real-world examples, use cases, and code samples that will enable you to get started on your Serverless applications quickly. By the end of the book, you will have gained all the skills required to work with AWS Lambda services!

Who is this book for?

If you are a Cloud administrator and/or developer who wishes to explore, learn, and leverage AWS Lambda to design, build, and deploy Serverless applications in the cloud, then this is the book for you! The book assumes you have some prior knowledge and hands-on experience with AWS core services such as EC2, IAM, S3, along with the knowledge to work with any popular programming language such as Node.Js, Java, C#, and so on.

What you will learn

  • • Understand the hype, significance, and business benefits of Serverless computing and applications
  • • Plunge into the Serverless world of AWS Lambda and master its core components and how it works
  • • Find out how to effectively and efficiently design, develop, and test Lambda functions using Node.js, along with some keen coding insights and best practices
  • • Explore best practices to effectively monitor and troubleshoot Serverless applications using AWS CloudWatch and other third-party services in the form of Datadog and Loggly
  • ? Quickly design and develop Serverless applications by leveraging AWS Lambda, DynamoDB, and API Gateway using the Serverless Application Framework (SAF) and other AWS services such as Step Functions
  • • Explore a rich variety of real-world Serverless use cases with Lambda and see how you can apply it to your environments

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Aug 11, 2017
Length: 300 pages
Edition : 1st
Language : English
ISBN-13 : 9781786467690
Vendor :
Amazon
Languages :
Concepts :
Tools :

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing

Product Details

Publication date : Aug 11, 2017
Length: 300 pages
Edition : 1st
Language : English
ISBN-13 : 9781786467690
Vendor :
Amazon
Languages :
Concepts :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
€189.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts
€264.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 106.97
Mastering AWS Lambda
€36.99
AWS Networking Cookbook
€36.99
AWS Automation Cookbook
€32.99
Total 106.97 Stars icon
Banner background image

Table of Contents

10 Chapters
Introducing AWS Lambda Chevron down icon Chevron up icon
Writing Lambda Functions Chevron down icon Chevron up icon
Testing Lambda Functions Chevron down icon Chevron up icon
Event-Driven Model Chevron down icon Chevron up icon
Extending AWS Lambda with External Services Chevron down icon Chevron up icon
Build and Deploy Serverless Applications with AWS Lambda Chevron down icon Chevron up icon
Monitoring and Troubleshooting AWS Lambda Chevron down icon Chevron up icon
Introducing the Serverless Application Framework Chevron down icon Chevron up icon
AWS Lambda - Use Cases Chevron down icon Chevron up icon
Next Steps with AWS Lambda Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Full star icon Empty star icon Empty star icon Empty star icon 2
(1 Ratings)
5 star 0%
4 star 0%
3 star 0%
2 star 100%
1 star 0%
Magesh.S Aug 14, 2023
Full star icon Full star icon Empty star icon Empty star icon Empty star icon 2
The images are very light. It has to be darker. When one buys book by paying that much cost the printing should be good. Packt has to improve printing. The book should have some value for the amount spent.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is included in a Packt subscription? Chevron down icon Chevron up icon

A subscription provides you with full access to view all Packt and licnesed content online, this includes exclusive access to Early Access titles. Depending on the tier chosen you can also earn credits and discounts to use for owning content

How can I cancel my subscription? Chevron down icon Chevron up icon

To cancel your subscription with us simply go to the account page - found in the top right of the page or at https://subscription.packtpub.com/my-account/subscription - From here you will see the ‘cancel subscription’ button in the grey box with your subscription information in.

What are credits? Chevron down icon Chevron up icon

Credits can be earned from reading 40 section of any title within the payment cycle - a month starting from the day of subscription payment. You also earn a Credit every month if you subscribe to our annual or 18 month plans. Credits can be used to buy books DRM free, the same way that you would pay for a book. Your credits can be found in the subscription homepage - subscription.packtpub.com - clicking on ‘the my’ library dropdown and selecting ‘credits’.

What happens if an Early Access Course is cancelled? Chevron down icon Chevron up icon

Projects are rarely cancelled, but sometimes it's unavoidable. If an Early Access course is cancelled or excessively delayed, you can exchange your purchase for another course. For further details, please contact us here.

Where can I send feedback about an Early Access title? Chevron down icon Chevron up icon

If you have any feedback about the product you're reading, or Early Access in general, then please fill out a contact form here and we'll make sure the feedback gets to the right team. 

Can I download the code files for Early Access titles? Chevron down icon Chevron up icon

We try to ensure that all books in Early Access have code available to use, download, and fork on GitHub. This helps us be more agile in the development of the book, and helps keep the often changing code base of new versions and new technologies as up to date as possible. Unfortunately, however, there will be rare cases when it is not possible for us to have downloadable code samples available until publication.

When we publish the book, the code files will also be available to download from the Packt website.

How accurate is the publication date? Chevron down icon Chevron up icon

The publication date is as accurate as we can be at any point in the project. Unfortunately, delays can happen. Often those delays are out of our control, such as changes to the technology code base or delays in the tech release. We do our best to give you an accurate estimate of the publication date at any given time, and as more chapters are delivered, the more accurate the delivery date will become.

How will I know when new chapters are ready? Chevron down icon Chevron up icon

We'll let you know every time there has been an update to a course that you've bought in Early Access. You'll get an email to let you know there has been a new chapter, or a change to a previous chapter. The new chapters are automatically added to your account, so you can also check back there any time you're ready and download or read them online.

I am a Packt subscriber, do I get Early Access? Chevron down icon Chevron up icon

Yes, all Early Access content is fully available through your subscription. You will need to have a paid for or active trial subscription in order to access all titles.

How is Early Access delivered? Chevron down icon Chevron up icon

Early Access is currently only available as a PDF or through our online reader. As we make changes or add new chapters, the files in your Packt account will be updated so you can download them again or view them online immediately.

How do I buy Early Access content? Chevron down icon Chevron up icon

Early Access is a way of us getting our content to you quicker, but the method of buying the Early Access course is still the same. Just find the course you want to buy, go through the check-out steps, and you’ll get a confirmation email from us with information and a link to the relevant Early Access courses.

What is Early Access? Chevron down icon Chevron up icon

Keeping up to date with the latest technology is difficult; new versions, new frameworks, new techniques. This feature gives you a head-start to our content, as it's being created. With Early Access you'll receive each chapter as it's written, and get regular updates throughout the product's development, as well as the final course as soon as it's ready.We created Early Access as a means of giving you the information you need, as soon as it's available. As we go through the process of developing a course, 99% of it can be ready but we can't publish until that last 1% falls in to place. Early Access helps to unlock the potential of our content early, to help you start your learning when you need it most. You not only get access to every chapter as it's delivered, edited, and updated, but you'll also get the finalized, DRM-free product to download in any format you want when it's published. As a member of Packt, you'll also be eligible for our exclusive offers, including a free course every day, and discounts on new and popular titles.