Hands-on serverless applications with Kotlin : develop scalable and cost-effective web applications using AWS Lambda and Kotlin.
2018
QA76.76.A65
Formats
Format | |
---|---|
BibTeX | |
MARCXML | |
TextMARC | |
MARC | |
DublinCore | |
EndNote | |
NLM | |
RefWorks | |
RIS |
Linked e-resources
Details
Title
Hands-on serverless applications with Kotlin : develop scalable and cost-effective web applications using AWS Lambda and Kotlin.
Author
ISBN
9781788991049 (electronic bk.)
1788991044 (electronic bk.)
9781788993708
1788991044 (electronic bk.)
9781788993708
Imprint
Birmingham : Packt Publishing Ltd, 2018.
Language
English
Description
1 online resource (378 pages)
Call Number
QA76.76.A65
System Control No.
(OCoLC)1056910175
Summary
Serverless architecture allows you to build and run applications and services without having to manage the infrastructure. This book will be your companion and guide to design serverless architectures for your applications with AWS and Kotlin. This book will help you build the client application and the backend functions serving it.
Formatted Contents Note
Cover
Title Page
Copyright and Credits
Packt Upsell
Contributors
Table of Contents
Preface
Chapter 1: Basics of Serverless
What is serverless computing?
The evolution of serverless computing
On-premise
Colocation providers
Virtualization and IaaS
PaaS
BaaS
SaaS
FaaS
Serverless computing
Serverless
the time is now
Diving into serverless computing with a use case
A review of serverless computing
Comparing and contrasting traditional and serverless paradigms
The case study of an application
The architecture of the system using traditional methods
The architecture of the system using the serverless paradigm
Traditional versus serverless, in a nutshell
Pros and cons of serverless
Advantages of serverless systems
Reduced operational costs
Optimized resource utilization
Faster time to market
High-development velocity and laser-sharp focus on authoring code
Promoting a microservices architecture
The drawbacks of serverless systems
Nascent ecosystem
Yielding of control
Opinionated offerings
Provider limits
Standardized and provider-agnostic offerings
Tooling
Competition from containers
Rethinking serverless
An absence of local states
Applying modern software development practices
Time-boxed execution
Startup latency
Testability
Debugging
The serverless computing ecosystem
Serverless computers and infrastructure providers
AWS Lambda
IBM OpenWhisk
Microsoft Azure Cloud Functions
Google Cloud Functions
Auth0 Webtasks
Others
Serverless toolkits
Summary
Chapter 2: AWS Serverless Offerings
AWS Lambda overview
Execution environment
Service limits
Invocation types
Custom invocation via AWS CLI or embedded AWS SDK in an application
Event sources from other AWS Services.
Execution environments/runtimes
Handler
Context
Logging
Exceptions and error handling
Storing the state
JVM execution environment
Handlers in Java
Context object
Logging
Error handling
A case study of a simple Java Lambda function
Creating the Lambda function
Lambda dashboard
Basics of creation
Configuring the Lambda function
Writing a Lambda function
Deploying the Lambda function
Testing a Lambda function
Case study of a simple Kotlin Lambda function
Tooling
Anatomy of a Kotlin Lambda function
Project structure
build.gradle
Handler
Packaging and deploying
Testing the Kotlin function
Integrating a Lambda function with an upstream component
Types API Gateway and Lambda integrations
Lambda integration/ Lambda custom integration
Lambda proxy integration
Anatomy of the Lambda function when used in Lambda proxy integration
Creating an API Gateway
Integration testing
Deploying the API Gateway
End-to-end test
Basic monitoring of lambda functions
Versioning Lambda functions
Summary
Chapter 3: Designing a Kotlin Serverless Application
The problem statement
Analyzing the problem statement
Functional specifications of the app
Designing the serverless API
Architectural and design decisions
AWS Cognito for login and registration
The Kotlin language
PostgresSQL 10 on Amazon RDS
API Gateway for proxy and edge engineering
API keys and usage plans
Authorization
Defining request and response models
API Gateway extensions to Swagger
Swagger 2.0 JSON documentation with API Gateway extensions
AWS Lambda as an FaaS platform
System design
Domain models
APIErrorResponseWithMessage
APISuccessResponseWithMessage
Poll
PollCreationRequest
RespondentDetails
PollResponseStatistics
API model.
Registering a respondent
Fetching all Polls
Creating a Poll
Fetching a Poll
Deleting a Poll
Responding to a Poll
Persistence layer design
Connecting to the instance
Configuring an application user
Schema definition
Security and access control to the API
API key
Cognito authorizer for API
Note on the local development environment
Setting up
AWS Account
Installing IntellIj Idea CE
PostgreSQL
Third-party libraries
Liquibase
JOOQ
Build life cycle
Summary
Chapter 4: Developing Your Serverless Application
Preparing the serverless environment
Configuring a Cognito pool
Swagger for the API
Implementing lambda functions
Writing your first lambda function in Kotlin
Choosing an IDE
Setting up a project
Writing a function that returns dummy static data
Data classes
Default parameters
Mutable list
Converting JSON into models using Jackson
The apply() function
Building a fat JAR
Deploying a JAR
Testing and executing
Implementing other lambda functions in Kotlin
Preparing the data classes
Registering respondents
Creating a poll
Getting a poll
Kotlin and the builder pattern
Implementation of the app
Setting up AWS Authentication using Cognito pool
Connecting to your backend
Object declaration
Integrating the API
Configuring the API client
Singleton
Lateinit versus lazy initialization
Lateinit
The lazy property
Interfaces
Rxify the API call
Lambda functions
Some interesting implementations
Returning data from a function
The destructuring declaration
Kotlin's approach to anonymous classes
Summary
Chapter 5: Improving Your App with Firebase Service
About Firebase
Firebase authentication
Configuring authentication methods.
Configuring the client app to use the authentication service
The when() expression
Improving the signIn() function using Lambda functions
Extension functions
Ditching the findViewById() method
View extensions
Firebase cloud functions
Prerequisites
Setting up the project
Creating a simple cloud function
Deploying the cloud function
Saving data into the real-time database
Structuring the request model
Structuring and saving the database object
Getting the list of polls
Interoperability with JavaScript
Monitoring crashes
Customizing the crash reports
Adding custom logs and keys
Monitoring the application's performance
How does it work?
Monitoring HTTP/s network requests
Using the SDK
Summary
Chapter 6: Analyzing Your Application
What are non-functional requirements?
AWS CloudTrail
AWS CloudWatch
AWS CloudTrail
Concepts
Overview
Event packet structure
Integrations
AWS services supported for CloudTrail auditing
AWS services not supported for CloudTrail auditing
Example
Creating a simple audit trail for auditing Lambda configurations
Creating a trail
Advanced configuration of the trail
The created trail
Trail repository
AWS CloudWatch
Concepts
Metrics
Namespaces
Logs
Alarms
Dashboards
A practical walk-through
Visualization using CloudWatch dashboards
Creating a dashboard for Greeter metrics
Creating a dashboard
Adding widgets
Metrics selection for Lambda
Creating a widget for the API Gateway metrics
Dashboard preview
Test run
Integration of CloudTrail and CloudWatch
Configuring CloudWatch with CloudTrail
Creating an IAM role
Verifying the integration
Summary
Chapter 7: Secure Your Application
AWS security concepts
Account access
Root credentials.
Enabling Multifactor authentication
Need based account creation
IAM groups
Password policy
IAM roles and policies
Subject/principal
Resources
Permissions
Policies
Groups
Roles
Identities
Users
Best practices for creating IAM users
Creating individual users
The principle of least privilege
Leveraging predefined policies
Rotating passwords and keys
Using temporary credentials
IAM policy conditions
Continuous and exhaustive monitoring
AWS Virtual Private Cloud
Subnets
Private subnets
Public subnets
Security groups
Inbound
Outbound
Infrastructure hardening
Hardening AWS Cognito
Security measures for users
Allowing user signup
Expiring unused accounts
Setting password policies
Enabling MFA
User verification
Hardening AWS API Gateway
SSL/HTTPS
API key and usage plans
Resource policies
Authorizers
CORS support
Throttling
Hardening AWS Lambda
Using KMS to encrypt sensitive information
Execution role
Hardening AWS RDS
Moving RDS into a VPC's private subnet
Do not use master credentials
Practical walk-through
Setting up the test bed
Database access using JOOQ
The build.gradle file
Handler
Invocation
Database configuration as environment variables
Defining environment variables
Modifying the handler to source these environment variables
Building and deploying
Invoking the API
Encrypting the environment variables
Configuring KMS
Creating a Key
Supplying key details
Defining administrative permissions
Defining usage permissions
Key created
Configuring Lambda with KMS
Enabling encryption in transit
Decrypting in the handler
Boilerplate decryption
The handler class
The build.gradle file
Deploying and testing
Creating an RDS user
Creating a user.
Title Page
Copyright and Credits
Packt Upsell
Contributors
Table of Contents
Preface
Chapter 1: Basics of Serverless
What is serverless computing?
The evolution of serverless computing
On-premise
Colocation providers
Virtualization and IaaS
PaaS
BaaS
SaaS
FaaS
Serverless computing
Serverless
the time is now
Diving into serverless computing with a use case
A review of serverless computing
Comparing and contrasting traditional and serverless paradigms
The case study of an application
The architecture of the system using traditional methods
The architecture of the system using the serverless paradigm
Traditional versus serverless, in a nutshell
Pros and cons of serverless
Advantages of serverless systems
Reduced operational costs
Optimized resource utilization
Faster time to market
High-development velocity and laser-sharp focus on authoring code
Promoting a microservices architecture
The drawbacks of serverless systems
Nascent ecosystem
Yielding of control
Opinionated offerings
Provider limits
Standardized and provider-agnostic offerings
Tooling
Competition from containers
Rethinking serverless
An absence of local states
Applying modern software development practices
Time-boxed execution
Startup latency
Testability
Debugging
The serverless computing ecosystem
Serverless computers and infrastructure providers
AWS Lambda
IBM OpenWhisk
Microsoft Azure Cloud Functions
Google Cloud Functions
Auth0 Webtasks
Others
Serverless toolkits
Summary
Chapter 2: AWS Serverless Offerings
AWS Lambda overview
Execution environment
Service limits
Invocation types
Custom invocation via AWS CLI or embedded AWS SDK in an application
Event sources from other AWS Services.
Execution environments/runtimes
Handler
Context
Logging
Exceptions and error handling
Storing the state
JVM execution environment
Handlers in Java
Context object
Logging
Error handling
A case study of a simple Java Lambda function
Creating the Lambda function
Lambda dashboard
Basics of creation
Configuring the Lambda function
Writing a Lambda function
Deploying the Lambda function
Testing a Lambda function
Case study of a simple Kotlin Lambda function
Tooling
Anatomy of a Kotlin Lambda function
Project structure
build.gradle
Handler
Packaging and deploying
Testing the Kotlin function
Integrating a Lambda function with an upstream component
Types API Gateway and Lambda integrations
Lambda integration/ Lambda custom integration
Lambda proxy integration
Anatomy of the Lambda function when used in Lambda proxy integration
Creating an API Gateway
Integration testing
Deploying the API Gateway
End-to-end test
Basic monitoring of lambda functions
Versioning Lambda functions
Summary
Chapter 3: Designing a Kotlin Serverless Application
The problem statement
Analyzing the problem statement
Functional specifications of the app
Designing the serverless API
Architectural and design decisions
AWS Cognito for login and registration
The Kotlin language
PostgresSQL 10 on Amazon RDS
API Gateway for proxy and edge engineering
API keys and usage plans
Authorization
Defining request and response models
API Gateway extensions to Swagger
Swagger 2.0 JSON documentation with API Gateway extensions
AWS Lambda as an FaaS platform
System design
Domain models
APIErrorResponseWithMessage
APISuccessResponseWithMessage
Poll
PollCreationRequest
RespondentDetails
PollResponseStatistics
API model.
Registering a respondent
Fetching all Polls
Creating a Poll
Fetching a Poll
Deleting a Poll
Responding to a Poll
Persistence layer design
Connecting to the instance
Configuring an application user
Schema definition
Security and access control to the API
API key
Cognito authorizer for API
Note on the local development environment
Setting up
AWS Account
Installing IntellIj Idea CE
PostgreSQL
Third-party libraries
Liquibase
JOOQ
Build life cycle
Summary
Chapter 4: Developing Your Serverless Application
Preparing the serverless environment
Configuring a Cognito pool
Swagger for the API
Implementing lambda functions
Writing your first lambda function in Kotlin
Choosing an IDE
Setting up a project
Writing a function that returns dummy static data
Data classes
Default parameters
Mutable list
Converting JSON into models using Jackson
The apply() function
Building a fat JAR
Deploying a JAR
Testing and executing
Implementing other lambda functions in Kotlin
Preparing the data classes
Registering respondents
Creating a poll
Getting a poll
Kotlin and the builder pattern
Implementation of the app
Setting up AWS Authentication using Cognito pool
Connecting to your backend
Object declaration
Integrating the API
Configuring the API client
Singleton
Lateinit versus lazy initialization
Lateinit
The lazy property
Interfaces
Rxify the API call
Lambda functions
Some interesting implementations
Returning data from a function
The destructuring declaration
Kotlin's approach to anonymous classes
Summary
Chapter 5: Improving Your App with Firebase Service
About Firebase
Firebase authentication
Configuring authentication methods.
Configuring the client app to use the authentication service
The when() expression
Improving the signIn() function using Lambda functions
Extension functions
Ditching the findViewById() method
View extensions
Firebase cloud functions
Prerequisites
Setting up the project
Creating a simple cloud function
Deploying the cloud function
Saving data into the real-time database
Structuring the request model
Structuring and saving the database object
Getting the list of polls
Interoperability with JavaScript
Monitoring crashes
Customizing the crash reports
Adding custom logs and keys
Monitoring the application's performance
How does it work?
Monitoring HTTP/s network requests
Using the SDK
Summary
Chapter 6: Analyzing Your Application
What are non-functional requirements?
AWS CloudTrail
AWS CloudWatch
AWS CloudTrail
Concepts
Overview
Event packet structure
Integrations
AWS services supported for CloudTrail auditing
AWS services not supported for CloudTrail auditing
Example
Creating a simple audit trail for auditing Lambda configurations
Creating a trail
Advanced configuration of the trail
The created trail
Trail repository
AWS CloudWatch
Concepts
Metrics
Namespaces
Logs
Alarms
Dashboards
A practical walk-through
Visualization using CloudWatch dashboards
Creating a dashboard for Greeter metrics
Creating a dashboard
Adding widgets
Metrics selection for Lambda
Creating a widget for the API Gateway metrics
Dashboard preview
Test run
Integration of CloudTrail and CloudWatch
Configuring CloudWatch with CloudTrail
Creating an IAM role
Verifying the integration
Summary
Chapter 7: Secure Your Application
AWS security concepts
Account access
Root credentials.
Enabling Multifactor authentication
Need based account creation
IAM groups
Password policy
IAM roles and policies
Subject/principal
Resources
Permissions
Policies
Groups
Roles
Identities
Users
Best practices for creating IAM users
Creating individual users
The principle of least privilege
Leveraging predefined policies
Rotating passwords and keys
Using temporary credentials
IAM policy conditions
Continuous and exhaustive monitoring
AWS Virtual Private Cloud
Subnets
Private subnets
Public subnets
Security groups
Inbound
Outbound
Infrastructure hardening
Hardening AWS Cognito
Security measures for users
Allowing user signup
Expiring unused accounts
Setting password policies
Enabling MFA
User verification
Hardening AWS API Gateway
SSL/HTTPS
API key and usage plans
Resource policies
Authorizers
CORS support
Throttling
Hardening AWS Lambda
Using KMS to encrypt sensitive information
Execution role
Hardening AWS RDS
Moving RDS into a VPC's private subnet
Do not use master credentials
Practical walk-through
Setting up the test bed
Database access using JOOQ
The build.gradle file
Handler
Invocation
Database configuration as environment variables
Defining environment variables
Modifying the handler to source these environment variables
Building and deploying
Invoking the API
Encrypting the environment variables
Configuring KMS
Creating a Key
Supplying key details
Defining administrative permissions
Defining usage permissions
Key created
Configuring Lambda with KMS
Enabling encryption in transit
Decrypting in the handler
Boilerplate decryption
The handler class
The build.gradle file
Deploying and testing
Creating an RDS user
Creating a user.
Source of Description
Online resource; title from PDF title page (EBSCO, viewed October 17, 2018)
Added Author
Linked Resources
Record Appears in