O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Hands-On Serverless Applications with Go

Book Description

Learn to build, secure, deploy, and manage your serverless application in Golang with AWS Lambda

Key Features

  • Implement AWS lambda to build scalable and cost-efficient applications in Go
  • Design and set the data flow between cloud services and custom business logic
  • Learn to design Lambda functions using real-world examples and implementation scenarios

Book Description

Serverless architecture is popular in the tech community due to AWS Lambda. Go is simple to learn, straightforward to work with, and easy to read for other developers; and now it's been heralded as a supported language for AWS Lambda. This book is your optimal guide to designing a Go serverless application and deploying it to Lambda.

This book starts with a quick introduction to the world of serverless architecture and its benefits, and then delves into AWS Lambda using practical examples. You'll then learn how to design and build a production-ready application in Go using AWS serverless services with zero upfront infrastructure investment. The book will help you learn how to scale up serverless applications and handle distributed serverless systems in production. You will also learn how to log and test your application.

Along the way, you'll also discover how to set up a CI/CD pipeline to automate the deployment process of your Lambda functions. Moreover, you'll learn how to troubleshoot and monitor your apps in near real-time with services such as AWS CloudWatch and X-ray. This book will also teach you how to secure the access with AWS Cognito.

By the end of this book, you will have mastered designing, building, and deploying a Go serverless application.

What you will learn

  • Understand how AWS Lambda works and use it to create an application
  • Understand how to scaleup serverless applications
  • Design a cost-effective serverless application in AWS
  • Build a highly scalable and fault-tolerant CI/CD pipeline
  • Understand how to troubleshoot and monitor serverless apps in AWS
  • Discover the working of APIs and single page applications
  • Build a production-ready serverless application in Go

Who this book is for

This book is for Go developers who would like to learn about serverless architecture. Go programming knowledge is assumed. DevOps and Solution Architects who are interested in building serverless applications in Go can also choose this book.

Downloading the example code for this book You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.

Table of Contents

  1. Title Page
  2. Copyright and Credits
    1. Hands-On Serverless Applications with Go
  3. Packt Upsell
    1. Why subscribe?
    2. PacktPub.com
  4. Contributors
    1. About the author
    2. About the reviewers
    3. Packt is searching for authors like you
  5. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
      1. Download the example code files
      2. Download the color images
      3. Conventions used
    4. Get in touch
      1. Reviews
  6. Go Serverless
    1. The serverless paradigm
      1. The cloud-computing evolution
        1. Infrastructure as a Service
        2. Platform as a Service
        3. Container as a Service
        4. Function as a Service
      2. Serverless architecture
        1. Benefits of going serverless
        2. Drawbacks of going serverless
        3. Serverless cloud providers
    2. AWS Lambda
      1. Source events
      2. Use cases
    3. Go serverless
    4. Summary
    5. Questions
  7. Getting Started with AWS Lambda
    1. Technical requirements
    2. Setting up the AWS environment
      1. The AWS command line
        1. Installing the AWS CLI
      2. AWS Management Console
        1. Configuration
        2. Testing
    3. Setting up the Go environment
      1. The runtime environment
      2. The development environment
    4. Summary
    5. Questions
  8. Developing a Serverless Function with Lambda
    1. Technical requirements
    2. Writing a Lambda function in Go
    3. Execution role
    4. Deployment package
      1. Uploading a ZIP file
      2. Uploading from Amazon S3
    5. Event testing
    6. Summary
    7. Questions
  9. Setting up API Endpoints with API Gateway
    1. Technical requirements
    2. Getting started with API Gateway
      1. Setting up an API endpoint
      2. Debugging and troubleshooting
      3. Invoking the function with an HTTP request
    3. Building a RESTful API
      1. API architecture
      2. Endpoints design
        1. The GET method
        2. The GET method with parameters
        3. The POST method
    4. Summary
  10. Managing Data Persistence with DynamoDB
    1. Technical requirements
    2. Setting up DynamoDB
      1. Creating a table
      2. Loading sample data
    3. Working with DynamoDB
      1. Scan request
      2. GetItem request
      3. PutItem request
      4. DeleteItem request
    4. Summary
    5. Questions
  11. Deploying Your Serverless Application
    1. Lambda CLI commands
      1. The list-functions command
      2. The create-function command
      3. The update-function-code command
      4. The get-function-configuration command
      5. The invoke command
      6. The delete-function command
    2. Versions and aliases 
      1. Versioning
        1. FindAllMovies v1.0.0
        2. FindAllMovies v1.1.0
      2. Semantic Versioning
      3. Aliases
      4. Stage variables
    3. Summary
  12. Implementing a CI/CD Pipeline
    1. Technical requirements
    2. Continuous Integration and deployment workflow
      1. Continuous Integration
      2. Continuous Deployment
      3. Continuous Delivery
    3. Automating the deployment of Lambda functions
      1. Continuous Deployment with CodePipeline and CodeBuild
        1. Source provider
        2. Build provider
        3. Deploy provider
      2. Continuous Pipeline with Jenkins
        1. Distributed builds
        2. Setting up a Jenkins job
        3. Git Hooks
      3. Continuous Integration with Circle CI
        1. Identity and access management
        2. Configuring the CI Pipeline
    4. Summary
    5. Questions
  13. Scaling Up Your Application
    1. Technical requirements
    2. Load testing and scaling
      1. Lambda autoscaling
      2. Downstream resources
      3. Private Lambda functions
    3. Concurrent execution
      1. Lambda throttling
      2. Concurrency reservation
    4. Summary
  14. Building the Frontend with S3
    1. Technical requirements
    2. Single Page Application
      1. Developing web applications with Angular
        1. Generating your first Angular component
        2. Accessing Rest web services with Angular
      2. Cross Origin Resource Sharing
    3. S3 static website hosting
      1. Setting up an S3 bucket
      2. Setting up Route 53
      3. Certificate Manager
      4. CloudFront distribution
      5. CI/CD workflow
    4. API documentation
    5. Summary
    6. Questions
  15. Testing Your Serverless Application
    1. Technical requirements
    2. Unit testing
      1. Automated unit tests
    3. Integration testing
      1. RPC communications
      2. Serverless Application Model
    4. Load testing
    5. Summary
    6. Questions
  16. Monitoring and Troubleshooting
    1. Monitoring and debugging with AWS CloudWatch
      1. CloudWatch metrics
      2. CloudWatch alarms
      3. CloudWatch logs
    2. Tracing with AWS X-Ray
    3. Summary
  17. Securing Your Serverless Application
    1. Technical requirements
    2. Authentication and user control access
      1. Securing API access
      2. User management with AWS Cognito
        1. Setting up a test user via the AWS Management Console
        2. Setup using Cognito Golang SDK
    3. Encrypted environment variables
      1. Data encryption at rest
      2. Data encryption in transit
    4. Logging AWS Lambda API calls with CloudTrail
    5. Vulnerability scanning for your dependencies
    6. Summary
    7. Questions
  18. Designing Cost-Effective Applications
    1. Lambda pricing model
      1. Lambda cost calculator
    2. Optimal memory size
    3. Code optimization
    4. Lambda cost and memory tracking
    5. Summary
  19. Infrastructure as Code
    1. Technical requirements
    2. Deploying AWS Lambda with Terraform
      1. Creating the Lambda function
      2. Setting up DynamoDB table
      3. Configuring API Gateway
      4. Cleaning up
    3. Deploying AWS Lambda with CloudFormation
      1. CloudFormation designer
    4. Deploying AWS Lambda with SAM
      1. Exporting a serverless application
    5. Summary
    6. Questions
  20. Assessments
    1. Chapter 1: Go Serverless
    2. Chapter 2: Getting Started with AWS Lambda
    3. Chapter 3: Developing a Serverless Function with Lambda
    4. Chapter 5: Managing Data Persistence with DynamoDB
    5. Chapter 7: Implementing a CI/CD Pipeline
    6. Chapter 9: Building the Frontend with S3
    7. Chapter 10: Testing Your Serverless Application
    8. Chapter 12: Securing Your Serverless Application
    9. Chapter 14: 
  21. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think