Programming AWS Lambda

Book description

Serverless revolutionizes the way organizations build and deploy software. With this hands-on guide, Java engineers will learn how to use their experience in the new world of serverless computing. You’ll discover how this cloud computing execution model can drastically decrease the complexity in developing and operating applications while reducing costs and time to market.

Engineering leaders John Chapin and Mike Roberts guide you through the process of developing these applications using AWS Lambda, Amazon’s event-driven, serverless computing platform. You’ll learn how to prepare the development environment, program Lambda functions, and deploy and operate your serverless software. The chapters include exercises to help you through each aspect of the process.

  • Get an introduction to serverless, functions as a service, and AWS Lambda
  • Learn how to deploy working Lambda functions to the cloud
  • Program Lambda functions and learn how the Lambda platform integrates with other AWS services
  • Build and package Java-based Lambda code and dependencies
  • Create serverless applications by building a serverless API and data pipeline
  • Test your serverless applications using automated techniques
  • Apply advanced techniques to build production-ready applications
  • Understand both the gotchas and new opportunities of serverless architecture

Publisher resources

View/Submit Errata

Table of contents

  1. Foreword
  2. Preface
    1. About This Book
    2. Why We Wrote This Book
    3. Who This Book Is For
    4. Why You Need This Book
    5. Using the End-of-Chapter Exercises
    6. Conventions Used in This Book
    7. Using Code Examples
    8. O’Reilly Online Learning
    9. How to Contact Us
    10. Acknowledgments
  3. 1. Introduction to Serverless, Amazon Web Services, and AWS Lambda
    1. A Quick History Lesson
    2. The Cloud Grows
    3. Enter Serverless
      1. Backend as a Service
      2. Functions as a Service
      3. Differentiating Serverless
    4. What Is AWS?
      1. Types of Service
      2. Capacity
      3. Who Uses AWS?
      4. How Do You Use AWS?
    5. What Is AWS Lambda?
      1. Functions as a Service
      2. FaaS as Implemented by Lambda
      3. Why Lambda?
      4. What Does a Lambda Application Look Like?
      5. AWS Lambda in the Java World
    6. Summary
    7. Exercises
  4. 2. Getting Started with AWS Lambda
    1. Quick Guide to the AWS Console
      1. Regions
      2. Identity and Access Management
    2. Lambda Hello World (as Quickly as Possible)
    3. Setting Up Your Development Environment
      1. AWS Command Line Interface
      2. Java Setup
      3. AWS SAM CLI Installation
    4. Lambda Hello World (the Proper Way)
      1. Creating Your First Java Lambda Project
      2. Building Hello World
      3. Creating the Lambda Function
    5. Summary
    6. Exercises
  5. 3. Programming AWS Lambda Functions
    1. Core Concepts: Runtime Model, Invocation
      1. The Lambda Execution Environment
      2. Invocation Types
      3. Introduction to Logging
    2. Input, Output
      1. Lambda Function Method Signatures
      2. Configuring the Handler Function in the SAM Template
      3. Basic Types
      4. Lists and Maps
      5. POJOs and Ecosystem Types
      6. Streams
      7. Context
    3. Timeout
    4. Memory and CPU
    5. Environment Variables
    6. Summary
    7. Exercises
  6. 4. Operating AWS Lambda Functions
    1. Build and Package
    2. Uberjars
    3. Assembling a ZIP File
    4. Reproducible Builds
    5. Deploy
    6. Infrastructure as Code
    7. CloudFormation and the Serverless Application Model
    8. Security
      1. The Principle of Least Privilege
      2. Identity and Access Management
    9. Summary
    10. Exercises
  7. 5. Building Serverless Applications
    1. Lambda Event Sources
      1. Writing Code to Work with Input and Output for Event Sources
      2. Configuring a Lambda Event Source
      3. Understanding Different Event Source Semantics
    2. Example: Building a Serverless API
      1. Behavior
      2. Architecture
      3. Lambda Code
      4. Build and Package Using the AWS SDK BOM
      5. Infrastructure
      6. Deployment
    3. Example: Building a Serverless Data Pipeline
      1. Behavior
      2. Architecture
      3. Lambda Code
      4. Build and Package Using Multiple Modules and Isolated Artifacts
      5. Infrastructure
      6. Deployment
    4. Summary
    5. Exercises
  8. 6. Testing
    1. The Test Pyramid
      1. Unit Tests
      2. Functional Tests
      3. End-to-End Tests
    2. Refactoring for Testing
    3. Revisiting BulkEventsLambda
    4. Refactoring BulkEventsLambda
      1. Add Constructors
      2. Isolate Side Effects
      3. Split Methods
    5. Testing BulkEventsLambda
      1. Unit Testing
      2. Functional Testing
    6. End-to-End Testing
    7. Local Cloud Testing
    8. Cloud Test Environments
    9. Summary
    10. Exercise
  9. 7. Logging, Metrics, and Tracing
    1. Logging
      1. CloudWatch Logs
      2. LambdaLogger
      3. Java Logging Frameworks
      4. Structured Logging
      5. Structured Logging in Java
      6. CloudWatch Logs Insights
    2. Metrics
      1. CloudWatch Metrics
      2. Lambda Platform Metrics
      3. Business Metrics
      4. Alarms
      5. Distributed Tracing
      6. Finding Errors
    3. Summary
    4. Exercises
  10. 8. Advanced AWS Lambda
    1. Error Handling
      1. Classes of Error
      2. The Various Behaviors of Lambda Error Processing
      3. Deep Dive into Asynchronous Event Source Errors
      4. Handling Kinesis and DynamoDB Stream Errors
      5. Tracing Errors with X-Ray
      6. Error Handling Strategies
    2. Scaling
      1. Observing Lambda Scaling
      2. Scaling Limits and Throttling
      3. Thread Safety
      4. Vertical Scaling
    3. Versions and Aliases, Traffic Shifting
      1. Lambda Versions
      2. Lambda Aliases
      3. Traffic Shifting
      4. When (Not) to Use Versions and Aliases
    4. Cold Starts
      1. What Is a Cold Start?
      2. When Does a Cold Start Occur?
      3. Identifying Cold Starts
      4. Impact of Cold Starts
      5. Mitigating Cold Starts
      6. Provisioned Concurrency
      7. Cold Start Summary
    5. State
      1. Persistent Application State
      2. Caching
    6. Lambda and Java Application Frameworks
    7. Virtual Private Clouds
      1. Architectural Concerns of Using Lambda with a VPCs
      2. Configuring Lambda to Use a VPC
      3. Alternatives
    8. Layers and Runtimes
      1. What Are Layers?
      2. When to Use, and Not Use, Layers
      3. Custom Runtimes
    9. Summary
    10. Exercises
  11. 9. Advanced Serverless Architecture
    1. Serverless Architecture “Gotchas”
      1. At-Least-Once Delivery
      2. Impacts of Lambda Scaling on Downstream Systems
      3. The “Fine Print” of Lambda Event Sources
    2. New Patterns of Architecture Enabled by Serverless Thinking
      1. Published Components with the Serverless Application Repository
      2. Globally Distributed Applications
    3. Summary
    4. Exercises
  12. 10. Conclusion
  13. Index

Product information

  • Title: Programming AWS Lambda
  • Author(s): John Chapin, Mike Roberts
  • Release date: March 2020
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9781492041054