Book Image

Hands-On Serverless Applications with Go

By : Mohamed Labouardy
Book Image

Hands-On Serverless Applications with Go

By: Mohamed Labouardy

Overview of this book

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.
Table of Contents (17 chapters)

Execution role

  1. Now that we have learned how to write our first Go Lambda function, let's create a new IAM role from Identity and Access Management (https://console.aws.amazon.com/iam/home) to grant the function access to AWS CloudWatch Logs:
  1. In the permissions page, you can either choose an existing AWS managed policy called CloudWatchFullAccess or (as shown in Step 3) create a least-privilege IAM role (the second option is recommended by AWS; a chapter dedicated to this will discuss security best practices for Lambda functions in depth):
  1. Go ahead and click on the Create policy button, and create a policy by selecting the appropriate service (CloudWatch) from the visual editor:
  1. For readers familiar with the JSON format, a JSON policy document can be used instead in the JSON tab. The document must have one statement that grants permissions to create log groups and...