go_serverless

module
v0.0.0-...-a078c91 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 6, 2023 License: MIT

README

go_serverless

test project for serverless go stack (aws)

Description

set-up similar to what is described in https://www.softkraft.co/aws-lambda-in-golang/ and in this tutorial.

More details and generic documentation can be found in AWS's docs, although that is referencing a HTTP API.

This is basically a CRUD API with Lambda and DynamoDB ___________________________________________________________ | AWS | _________ | __________ ________________________ __________ | The set-up is basically | clients | -> | | REST API | -> | Golang Lamda Function | -> | DynamoDB | | || | || |_______________________| |_________| | |___________________________________________________________|

The golang (amd64 arch) build needs to be uploaded to the Lambda function and then one needs to set-up Dynamo DB with the name go_serverless or whatever value is specified in main.go by the tableName const.

The Lamda function needs to have the Simple microservice permission policy applied to it.

Then the Amazon API Gateway (REST) needs to be set-up. The result of the set-up will be a URL value that is usable by external clients to hit the Lamda function (https://ssh***********c.execute-api.eu-central-1.amazonaws.com/vlad in my case)

One can then test if this all worked with the following curl commands:

  • Add new User:

curl --header "Content-Type: application/json" --request POST --data '{"email": "some.user@client.com", "firstName": "Some", "lastName": "User"}' https://ssh***********c..execute-api.eu-central-1.amazonaws.com/vlad

  • GET all users

curl -X GET https://ssh***********c..execute-api.eu-central-1.amazonaws.com/vlad

  • Get a single user by email

curl -X GET https://ssh***********c..execute-api.eu-central-1.amazonaws.com/vlad?email=some.user@client.com

  • Update User

curl --header "Content-Type: application/json" --request PUT --data '{"email": "some.user@client.com", "firstName": "Other", "lastName": "User"}' https://ssh***********c..execute-api.eu-central-1.amazonaws.com/vlad

  • Delete a user

curl -X DELETE https://ssh***********c..execute-api.eu-central-1.amazonaws.com/vlad?email=some.user@client.com

Directories

Path Synopsis
pkg

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL