Serverless Programming Cookbook
eBook - ePub

Serverless Programming Cookbook

Practical solutions to building serverless applications using Java and AWS

  1. 490 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Serverless Programming Cookbook

Practical solutions to building serverless applications using Java and AWS

About this book

Build, secure, and deploy real-world serverless applications in AWS and peek into the serverless cloud offerings from Azure, Google Cloud, and IBM Cloud

Key Features

  • Build serverless applications with AWS Lambda, AWS CloudFormation and AWS CloudWatch
  • Perform data analytics and natural language processing(NLP)on the AWS serverless platform
  • Explore various design patterns and best practices involved in serverless computing

Book Description

Managing physical servers will be a thing of the past once you're able to harness the power of serverless computing. If you're already prepped with the basics of serverless computing, Serverless Programming Cookbook will help you take the next step ahead. This recipe-based guide provides solutions to problems you might face while building serverless applications.

You'll begin by setting up Amazon Web Services (AWS), the primary cloud provider used for most recipes. The next set of recipes will cover various components to build a Serverless application including REST APIs, database, user management, authentication, web hosting, domain registration, DNS management, CDN, messaging, notifications and monitoring. The book also introduces you to the latest technology trends such as Data Streams, Machine Learning and NLP. You will also see patterns and practices for using various services in a real world application. Finally, to broaden your understanding of Serverless computing, you'll also cover getting started guides for other cloud providers such as Azure, Google Cloud Platform and IBM cloud.

By the end of this book, you'll have acquired the skills you need to build serverless applications efficiently using various cloud offerings.

What you will learn

  • Serverless computing in AWS and explore services with other clouds
  • Develop full-stack apps with API Gateway, Cognito, Lambda and DynamoDB
  • Web hosting with S3, CloudFront, Route 53 and AWS Certificate Manager
  • SQS and SNS for effective communication between microservices
  • Monitoring and troubleshooting with CloudWatch logs and metrics
  • Explore Kinesis Streams, Amazon ML models and Alexa Skills Kit

Who this book is for

For developers looking for practical solutions to common problems while building a serverless application, this book provides helpful recipes. To get started with this intermediate-level book, knowledge of basic programming is a must.

Frequently asked questions

Yes, you can cancel anytime from the Subscription tab in your account settings on the Perlego website. Your subscription will stay active until the end of your current billing period. Learn how to cancel your subscription.
No, books cannot be downloaded as external files, such as PDFs, for use outside of Perlego. However, you can download books within the Perlego app for offline reading on mobile or tablet. Learn more here.
Perlego offers two plans: Essential and Complete
  • Essential is ideal for learners and professionals who enjoy exploring a wide range of subjects. Access the Essential Library with 800,000+ trusted titles and best-sellers across business, personal growth, and the humanities. Includes unlimited reading time and Standard Read Aloud voice.
  • Complete: Perfect for advanced learners and researchers needing full, unrestricted access. Unlock 1.4M+ books across hundreds of subjects, including academic and specialized titles. The Complete Plan also includes advanced features like Premium Read Aloud and Research Assistant.
Both plans are available with monthly, semester, or annual billing cycles.
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Yes! You can use the Perlego app on both iOS or Android devices to read anytime, anywhere — even offline. Perfect for commutes or when you’re on the go.
Please note we cannot support devices running on iOS 13 and Android 7 or earlier. Learn more about using the app.
Yes, you can access Serverless Programming Cookbook by Heartin Kanikathottu in PDF and/or ePUB format, as well as other popular books in Computer Science & Cloud Computing. We have over one million books available in our catalogue for you to explore.

Information

Redshift, Amazon ML, and Alexa Skills

This chapter will cover the following topics:
  • Your first Kinesis data stream (KDS): AWS Command Line Interface (CLI)
  • Writing data into KDS with SDK (Java)
  • Invoking Lambda with a Kinesis event (Java)
  • Using Amazon ML for binary classification (AWS CLI)
  • Building and testing an Alexa skill (Java for Lambda, CLI for Alexa skills)

Introduction

In this chapter, I will introduce you to some services that can help you to perform analytics and Natural Language Processing (NLP) on the AWS cloud, such as Amazon KDS, the Amazon Machine Learning (ML) service, and the Alexa Skills Kit. KDS is primarily used for building data pipelines for big data applications. We will also look at a basic recipe each for the ML service and the Alexa Skills Kit. To learn more about these services, you can refer to any Packt book on data analytics, ML, and NLP.
You will require the following skill sets to complete the recipes in this chapter:
  • Knowledge of how to work on AWS account
  • Knowledge of how to configure AWS CLI, as discussed in the Your first Lambda with AWS CLI recipe in Chapter 1, Getting Started with Serverless Computing on AWS
  • A basic understanding of data analytics, ML, and NLP concepts
Keep in mind that not all services and features discussed in this chapter may be eligible for free use. Please refer to AWS Free Tier documentation for details.

Your first Kinesis data stream (AWS CLI)

In the previous chapter, we learned how we can use SQS for messaging. SQS is good for standard data transfer (messaging) within serverless microservice applications; however, applications that work on big data and data analytics demand more. KDS is a highly scalable data streaming service that is used for such use cases.
KDS consists of an ordered sequence of data records. A stream is composed of multiple shards with different unique sequences of data records. A partition key is used to group data into shards. In the following recipe, we will create a simple KDS, put data into the stream, and retrieve data from the stream, all using AWS CLI.

Getting ready

There are no additional prerequisites for completing this recipe other than the common requirements specified in this chapter's introduction.

How to do it...

We will first create the KDS and later test it using AWS CLI commands.

Step 1 - Creating a Kinesis data stream

We will create the KDS using both AWS CLI commands and the CloudFormation template.

Using AWS CLI

We can create a KDS from the AWS CLI as follows:
aws kinesis create-stream \
--stream-name my-first-kinesis-stream \
--shard-count 1 \
--profile admin
This command will not return anything. You may use the aws kinesis describe-stream command to get the details of the stream:
aws kinesis describe-stream \
--stream-name my-first-kinesis-stream \
--profile admin
If stream creation happened successfully, you should see the StreamStatus as ACTIVE, as shown in the following screenshot:
You can also list the streams available using aws kinesis list-streams, as shown in the following code:
aws kinesis list-streams \
--profile admin
This should return the following response in our case (assuming you have only one stream):

Using the CloudFormation template

You can create a CloudFormation template file with the following Resource and Outputs sections to create a simple KDS:
Resources:
KinesisStream:
Type: AWS::Kinesis::Stream
Properties:
Name: my-first-kinesis-stream
RetentionPeriodHours: 24
ShardCount: 1

Outputs:
KinesisStreamId:
Value: !Ref KinesisStream
Export:
Name: "KinesisStreamId"
KinesisStreamArn:
Value: !GetAtt KinesisStream.Arn
Export:
Name: "KinesisStreamArn"
You may also add a template version and description to the top of the template file and then execute the stack using the aws cloudformation create-stack command. The complete commands and the template are avail...

Table of contents

  1. Title Page
  2. Copyright and Credits
  3. Dedication
  4. About Packt
  5. Contributors
  6. Preface
  7. Getting Started with Serverless Computing on AWS
  8. Building Serverless REST APIs with API Gateway
  9. Data Storage with Amazon DynamoDB
  10. Application Security with Amazon Cognito
  11. Web Hosting with S3, Route53, and CloudFront
  12. Messaging and Notifications with SQS and SNS
  13. Redshift, Amazon ML, and Alexa Skills
  14. Monitoring and Alerting with Amazon CloudWatch
  15. Serverless Programming Practices and Patterns
  16. Other Cloud Providers
  17. Other Books You May Enjoy