All Projects → cpliakas → Aws Sam Golang Example

cpliakas / Aws Sam Golang Example

Licence: mit
An example API and Worker written in Golang using the Amazon Serverless Application Model (AWS SAM)

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects

Projects that are alternatives of or similar to Aws Sam Golang Example

lambda-facebook-oauth
An AWS Lambda function to facilitate Oauth2 social login with Facebook
Stars: ✭ 16 (-78.08%)
Mutual labels:  aws-lambda, aws-apigateway
Serverless Photo Recognition
A collection of 3 lambda functions that are invoked by Amazon S3 or Amazon API Gateway to analyze uploaded images with Amazon Rekognition and save picture labels to ElasticSearch (written in Kotlin)
Stars: ✭ 345 (+372.6%)
Mutual labels:  aws-lambda, aws-apigateway
aws-lambda-firewall
Securely and conveniently support IP address whitelists for your publicly routable services.
Stars: ✭ 16 (-78.08%)
Mutual labels:  aws-lambda, aws-apigateway
Aws Lambda Typescript
This sample uses the Serverless Application Framework to implement an AWS Lambda function in TypeScript, deploy it via CloudFormation, publish it through API Gateway to a custom domain registered on Route53, and document it with Swagger.
Stars: ✭ 228 (+212.33%)
Mutual labels:  aws-lambda, aws-apigateway
Aws Lambda Dotnet
Libraries, samples and tools to help .NET Core developers develop AWS Lambda functions.
Stars: ✭ 945 (+1194.52%)
Mutual labels:  aws-lambda, aws-apigateway
aws-sync-routes
Synchronizes the specified route from the main/default route table to all custom route tables in the VPC.
Stars: ✭ 16 (-78.08%)
Mutual labels:  aws-lambda, aws-apigateway
Aws Lambda Graphql
Use AWS Lambda + AWS API Gateway v2 for GraphQL subscriptions over WebSocket and AWS API Gateway v1 for HTTP
Stars: ✭ 313 (+328.77%)
Mutual labels:  aws-lambda, aws-apigateway
Awsmobile Cli
CLI experience for Frontend developers in the JavaScript ecosystem.
Stars: ✭ 147 (+101.37%)
Mutual labels:  aws-lambda, aws-apigateway
Cloudmagick
CloudMagick is a serverless application which provides a dynamic image transformation like the small light module of apache2
Stars: ✭ 11 (-84.93%)
Mutual labels:  aws-lambda, aws-apigateway
Aws Serverless Auth Reference App
Serverless reference app and backend API, showcasing authentication and authorization patterns using Amazon Cognito, Amazon API Gateway, AWS Lambda, and AWS IAM.
Stars: ✭ 724 (+891.78%)
Mutual labels:  aws-lambda, aws-apigateway
Apilogs
Easy logging and debugging for Amazon API Gateway and AWS Lambda Serverless APIs
Stars: ✭ 216 (+195.89%)
Mutual labels:  aws-lambda, aws-apigateway
Chalice
Python Serverless Microframework for AWS
Stars: ✭ 8,513 (+11561.64%)
Mutual labels:  aws-lambda, aws-apigateway
Aws Csa Notes 2018
My AWS Certified Solutions Architect Associate Study Notes!
Stars: ✭ 167 (+128.77%)
Mutual labels:  aws-lambda, aws-apigateway
hyper-kube-config
H Y P E R K U B E - A Serverless API and kubectl plugin providing a storage and retrieval Kubernetes cluster credentials. Hyperkube leverages AWS Secrets Manager for storing credential information.
Stars: ✭ 27 (-63.01%)
Mutual labels:  aws-lambda, aws-apigateway
Archive aws Lambda Go Net
Network I/O interface for AWS Lambda Go runtime.
Stars: ✭ 151 (+106.85%)
Mutual labels:  aws-lambda, aws-apigateway
terraform-lambda-example
Hello World example of AWS Lambda
Stars: ✭ 35 (-52.05%)
Mutual labels:  aws-lambda, aws-apigateway
Architect
The simplest, most powerful way to build serverless applications
Stars: ✭ 1,925 (+2536.99%)
Mutual labels:  aws-lambda, aws-apigateway
Serverless Sam
Serverless framework plugin to export AWS SAM templates for a service
Stars: ✭ 143 (+95.89%)
Mutual labels:  aws-lambda, aws-apigateway
Serverless Offline
Emulate AWS λ and API Gateway locally when developing your Serverless project
Stars: ✭ 4,330 (+5831.51%)
Mutual labels:  aws-lambda, aws-apigateway
Terraform Sqs Lambda Trigger Example
Example on how to create a AWS Lambda triggered by SQS in Terraform
Stars: ✭ 31 (-57.53%)
Mutual labels:  aws-lambda, example

AWS SAM Golang Example

Build Status Go Report Card

An example API and Worker written in Golang using the Amazon Serverless Application Model (AWS SAM).

Overview

Go is arguably one of the easiest languages in which to write a RESTful API. With the addition of Go support for AWS Lambda coupled with the maturity of tooling around the AWS Serverless Application Model, deploying Golang-based APIs to serverless infrastructure is becoming much more straightforward, too. Thanks to the APEX Gateway, you can even write APIs in a familiar manner without changing how the code is structured.

The purpose of this project is to give a slightly more complicated example than the "hello world" ones provided by Amazon with a toolchain that supports both local development and deployment to AWS as well as design patterns that facilitate unit testing.

Prerequisites

Installation

With a correctly configured Go toolchain:

go get github.com/cpliakas/aws-sam-golang-example/...
cd $GOPATH/src/github.com/cpliakas/aws-sam-golang-example

Usage

Run the API Locally

⚠️ Make sure to install all the Prerequisites. On Mac OSX and Windows, ensure that the Docker VM is running.

GOARCH=amd64 GOOS=linux go build -o api ./service/api
sam local start-api

or ...

make run

You can now consume the API using your tool of choice. HTTPie is pretty awesome.

http localhost:3000/
HTTP/1.1 200 OK
Content-Length: 28
Content-Type: application/json; charset=utf8
Date: Sat, 03 Feb 2018 20:12:07 GMT

{
    "message": "Hello, world!"
}

Run the Worker Locally

TODO

Deploy to AWS

First, set the following environment variables replacing <MY-BUCKET-NAME> and <MY-STACK-NAME> as appropriate:

export S3_BUCKET="<MY-BUCKET-NAME>"
export STACK_NAME="<MY-STACK-NAME>"

Now build, package, and deploy the application:

GOOS=linux GOARCH=amd64 go build -o api ./service/api
GOOS=linux GOARCH=amd64 go build -o error ./service/error
GOOS=linux GOARCH=amd64 go build -o worker ./service/worker

sam package --template-file template.yaml --s3-bucket $S3_BUCKET --output-template-file packaged.yaml
sam deploy --stack-name $STACK_NAME --template-file packaged.yaml --capabilities CAPABILITY_IAM

or ...

make deploy

Consume the Endpoint

The API endpoint is captured in the CloudFormation stack's Endpoint output key. Either view the output value via the AWS Management Console, or run the following command assuming the jq tool is installed:

aws cloudformation describe-stacks --stack-name $STACK_NAME | jq -r '.Stacks[0].Outputs[0].OutputValue'

Again, HTTPie is a pretty awesome tool.

View AWS Logs

Run the following command to get the CloudWatch logs for the API.

sam logs -n Api --stack-name $STACK_NAME

Replace Api with Worker or Error to get logs for the Lambda functions in those resources as well.

⚠️ The sam tool will throw a nasty stack trace if you try to view the logs before the Lambda function has been invoked. Only run this command after you have made requests to the corresponding handlers.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].