Building Serverless Architectures Learn The Intricacies and Nuances of Building Efficient Serverless Architectures First Published Edition Gurturk
Building Serverless Architectures Learn The Intricacies and Nuances of Building Efficient Serverless Architectures First Published Edition Gurturk
com
OR CLICK BUTTON
DOWNLOAD NOW
https://textbookfull.com/product/serverless-development-on-aws-
building-enterprise-scale-serverless-solutions-1st-edition-sheen-
brisals/
textboxfull.com
https://textbookfull.com/product/serverless-architectures-on-aws-
second-edition-meap-v06-peter-sbarski-yan-cui-ajay-nair/
textboxfull.com
https://textbookfull.com/product/building-evolutionary-architectures-
support-constant-change-1st-edition-neal-ford/
textboxfull.com
Mastering Azure Serverless Computing Design and Implement
End to End Highly Scalable Azure Serverless Solutions with
Ease 1st Edition Abhishek Mishra
https://textbookfull.com/product/mastering-azure-serverless-computing-
design-and-implement-end-to-end-highly-scalable-azure-serverless-
solutions-with-ease-1st-edition-abhishek-mishra/
textboxfull.com
https://textbookfull.com/product/botnets-architectures-
countermeasures-and-challenges-first-edition-edition-anagnostopoulos/
textboxfull.com
https://textbookfull.com/product/flexible-network-architectures-
security-principles-and-issues-first-edition-rudra/
textboxfull.com
https://textbookfull.com/product/modern-fortran-building-efficient-
parallel-applications-1st-edition-milan-curcic/
textboxfull.com
https://textbookfull.com/product/modern-fortran-building-efficient-
parallel-applications-1st-edition-milan-curcic-2/
textboxfull.com
Building Serverless Architectures
BIRMINGHAM - MUMBAI
< html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd">
Building Serverless
Architectures
Every effort has been made in the preparation of this book to ensure the
accuracy of the information presented. However, the information contained in
this book is sold without warranty, either express or implied. Neither the
author, nor Packt Publishing, and its dealers and distributors will be held
liable for any damages caused or alleged to be caused directly or indirectly
by this book.
ISBN 978-1-78712-919-1
www.packtpub.com
Credits
Technical Editor
Dhiraj Chandanshive
About the Author
Cagatay Gurturk is a software engineer, internet enterpreneur, and cloud
enthusiast.
I would like to express my gratitude to the many people who helped and
supported me throughout this book, and to all those who read, wrote,
offered comments, and assisted me in the editing, proofreading, and
designing of this book.
I would like to thank Martin Lindenburg for reviewing every line of this
book and bringing his German perfectionism.
And, finally, I would like to thank everyone who motivated me for this
work.
About the Reviewer
Martin Lindenburg is a software engineer born in 1982. He grew up in a
rural region, about 100 km north of Berlin. He developed his interest in
computers and technology at a young age with his brother's Commodore64.
Later, he invested all his pocket money to afford his first own 386 computer,
where he developed his first programs in Basic and Turbo Pascal to
visualize and solve his math homework. This interest evolved, and, a few
years later, he finally ended up studying computer engineering in Berlin.
He is now working for more than ten years as a software engineer, and he has
worked for companies in the telecommunication group, Deutsche Telekom
AG, the financial portal, Wallstreet-Online AG, and the advertisement and
affiliate network, ADCELL. He collected experiences from the creation of
standalone applications over scalable dynamic webpages with hundreds of
users logging in up to millions of daily page views and tracking events.
Thanks to Cagatay Gurturk for letting me review his book and a special
thanks to my wife, Maria, and my children, Samuel and Simon, for their
patience in the evenings when I had to review new chapters.
www.PacktPub.com
For support files and downloads related to your book, please visit www.PacktP
ub.com.
Did you know that Packt offers eBook versions of every book published,
with PDF and ePub files available? You can upgrade to the eBook version at
www.PacktPub.comand as a print book customer, you are entitled to a discount
on the eBook copy. Get in touch with us at [email protected] for more
details.
https://www.packtpub.com/mapt
Get the most in-demand software skills with Mapt. Mapt gives you full
access to all Packt books and video courses, as well as industry-leading
tools to help you plan your personal development and advance your career.
Why subscribe?
Fully searchable across every book published by Packt
Copy and paste, print, and bookmark content
On demand and accessible via a web browser
Customer Feedback
Thanks for purchasing this Packt book. At Packt, quality is at the heart of our
editorial process. To help us improve, please leave us an honest review on
this book's Amazon page at https://www.amazon.com/dp/1787129195.
If you'd like to join our team of regular reviewers, you can e-mail us at
[email protected]. We award our regular reviewers with free
eBooks and videos in exchange for their valuable feedback. Help us be
relentless in improving our products!
Table of Contents
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. Getting Started with Serverless
Preparing the environment
Installing AWS CLI
Prerequisites
Gradle
Creating the project
Implementing the Lambda Dependency
Hello Lambda!
Deploying to the Cloud
Summary
Bibliography
2. Infrastructure as a Code
Uploading the artifacts to Cloud
Infrastructure as Code with CloudFormation
Deploying our first Lambda with CloudFormation
Summary
3. Hello Internet
Setting up API Gateway
Creating the API
Creating the resource
Creating the method
Configuring Lambda permissions
Deploying the API
Setting up the CloudFront CDN distribution
Setting up the custom domain
Creating an SSL certificate
Authenticating API calls
Implementing basic authorization
Summary
4. Applying Enterprise Patterns
Creating User Service
Configuring Guice
Writing the Lambda Handler class with injected dependency
Adding logging
Service dependencies
Summary
5. Persisting Data
Introduction to DynamoDB
Creating the first table
Creating the second table for access tokens
Configuring the DynamoDB data mapper
Configuring environment variables for Lambda
User registration
Creating user registration Lambda
Creating the Lambda and API Gateway for User Registration
Summary
6. Building Supporting Services
Writing the foundation of a Lambda function
Letting users upload to S3
Modifying the Lambda function to respond to an S3 event
Configuring CloudFront to serve resized images
Excercise
Sending emails via SES
Configuring SES
Firing an SNS notification upon user registration
Consuming the SNS message and sending emails
Integrating a messaging queue
Summary
7. Searching Data
Creating the search domain
Uploading test data
Creating the suggester
Creating the API endpoint for suggestions
Lambda function for updating search data
Modifying the welcome mail sender Lambda
Creating the Lambda function to update CloudSearch
Creating and configuring the Lambda function with CloudFormat
ion
Summary
8. Monitoring, Logging, and Security
Setting up a Route53 health check
Starting off with the setup
Configuring health checks for email notifications
Enabling SMS notifications for health checks
Bringing health check to healthy mode
Mastering CloudWatch alarms
Configuring advanced CloudWatch alarms
Wrapping everything up in CloudFormation
Creating CloudWatch metrics from application logs
Running Lambda functions in VPC
Creating a VPC
Adding private subnets
Handling inbound and outbound traffic
Creating a Security Group
Summary
9. Lambda Framework
Getting to know Lambda Framework
Summary
Preface
Over the past few years, all kind of companies, ranging from start-ups to
giant enterprises, have started their move to public cloud providers in order
to save their costs and reduce the operational effort needed to keep their
shops open. While this movement was applied with just a lift and shift
strategy, keeping their software architecture the same and only changing
where they are hosting it, some companies opted for a mindset change,
modifying their software to take advantage of native cloud services other
than virtual machines, changing their team structures, and adopting DevOps
practices. This opened the door to many changes in the software industry, and
it is definitely possible to say that the world after the introduction of cloud
computing is not the same as before.
The focus of this book is to design serverless architectures, and weigh the
advantages and disadvantages of this approach, along with a few decision
factors to consider. You will learn how to design a serverless application,
get to know the key points of services that serverless applications are based
on, and known issues and solutions. In this book, you will not only learn the
AWS Lambda functions, but you will also see how to use the Lambda
functions to glue other AWS services together. You will learn how easy it is
to build a scalable software system is, taking a CRUD application as an
example.
The book addresses key challenges, such as how to slice out the core
functionality of the software to be distributed in different cloud services and
cloud functions. It covers the basic and advanced usage of these services,
testing and securing the serverless software, automating deployment, and
more.
Throughout this book, we will only use the Java programming language, and
we will build a homegrown deployment system to easily deploy our
software.
This book does not intend to cover all the details of the AWS ecosystem, but I
believe it will perfectly show you the path through the serverless computing
world.
What this book covers
Chapter 1,Getting Started With Serverless, introduces you to serverless
computing and Lambda functions, sets up the AWS account and environment,
and builds the base libraries.
Chapter 3,
Hello Internet, exposes the Lambda function to the internet via the
AWS API Gateway.
Chapter 4,
Applying Enterprise Patterns, implements and configures the
dependency injection pattern for the Lambda function.
Appendix,
Lambada Framework, migrates your JAX-RS application to AWS
Lambda and API Gateway with minimal effort.
What you need for this book
To run all the code in this book, you only need to have the Java Development
Kit installed on your machine. You will have to create an AWS account to
apply the steps. AWS offers a free tier for new customers that will cover
most of the costs of running examples in the book. On the other hand, some
services such as CloudSearch and VPC NAT Gateways are not covered by a
free tier. Make sure that you visit the pricing documentation of each service
used in the book to avoid unnecessary costs.
Who this book is for
This book is for developers and software architects who are interested in
designing their software in serverless environments. Since the programming
language used in this book is Java, it is preferred that readers are familiar
with the basics of Java and the general conventions used in the Java world.
Conventions
In this book, you will find a number of text styles that distinguish between
different kinds of information. Here are some examples of these styles and an
explanation of their meaning.
Code words in text, database table names, folder names, filenames, file
extensions, pathnames, dummy URLs, user input, and Twitter handles are
shown as follows: "We can start by adding the next snippet to the
build.gradle file."
cloudFormation {
capabilityIam true
templateFile project.file('cloudformation.template')
templateBucket deploymentBucketName
templateKeyPrefix "cfn-templates"
stackName "serverlessbook"
}
$ touch cloudformation.template
New terms and important words are shown in bold. Words that you see on
the screen, for example, in menus or dialog boxes, appear in the text like this:
"In order to download new modules, we will go to Files | Settings | Project
Name | Project Interpreter."
Once the file is downloaded, please make sure that you unzip or extract the
folder using the latest version of:
The code bundle for the book is also hosted on GitHub at https://github.com/
PacktPublishing/Building-Serverless-Architectures. We also have other code
bundles from our rich catalog of books and videos available at https://githu
b.com/PacktPublishing/. Check them out!
Errata
Although we have taken every care to ensure the accuracy of our content,
mistakes do happen. If you find a mistake in one of our books-maybe a
mistake in the text or the code-we would be grateful if you could report this
to us. By doing so, you can save other readers from frustration and help us
improve subsequent versions of this book. If you find any errata, please
report them by visiting http://www.packtpub.com/submit-errata, selecting your
book, clicking on the Errata Submission Form link, and entering the details of
your errata. Once your errata are verified, your submission will be accepted
and the errata will be uploaded to our website or added to any list of existing
errata under the Errata section of that title. To view the previously submitted
errata, go to https://www.packtpub.com/books/content/support and enter the
name of the book in the search field. The required information will appear
under the Errata section.
Piracy
Piracy of copyrighted material on the Internet is an ongoing problem across
all media. At Packt, we take the protection of our copyright and licenses very
seriously. If you come across any illegal copies of our works in any form on
the Internet, please provide us with the location address or website name
immediately so that we can pursue a remedy. Please contact us at
[email protected] with a link to the suspected pirated material. We
appreciate your help in protecting our authors and our ability to bring you
valuable content.
Questions
If you have a problem with any aspect of this book, you can contact us at
[email protected], and we will do our best to address the problem.
Discovering Diverse Content Through
Random Scribd Documents
The Project Gutenberg eBook of Miss Harriet
This ebook is for the use of anyone anywhere in the United States
and most other parts of the world at no cost and with almost no
restrictions whatsoever. You may copy it, give it away or re-use it
under the terms of the Project Gutenberg License included with this
ebook or online at www.gutenberg.org. If you are not located in the
United States, you will have to check the laws of the country where
you are located before using this eBook.
Language: Hungarian
GUY DE MAUPASSANT
ÖSSZES MŰVEI
IX.
BUDAPEST
AZ ATHENAEUM IRODALMI ÉS NYOMDAI R.-T. KIADÁSA
GUY DE MAUPASSANT
MISS HARRIET
FORDÍTOTTA
TÓTH ÁRPÁD
BUDAPEST
AZ ATHENAEUM IRODALMI ÉS NYOMDAI R.-T. KIADÁSA
I.
II.
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
textbookfull.com