https://github.com/go-serverless/serverless-iam-dynamodb
Building serverless CRUD services in Go with DynamoDB
https://github.com/go-serverless/serverless-iam-dynamodb
api-gateway aws crud dynamodb golang lambda serverless serverless-crud-services
Last synced: 5 months ago
JSON representation
Building serverless CRUD services in Go with DynamoDB
- Host: GitHub
- URL: https://github.com/go-serverless/serverless-iam-dynamodb
- Owner: go-serverless
- Created: 2019-12-28T11:21:31.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2021-10-16T04:11:02.000Z (over 4 years ago)
- Last Synced: 2024-12-27T07:42:32.378Z (over 1 year ago)
- Topics: api-gateway, aws, crud, dynamodb, golang, lambda, serverless, serverless-crud-services
- Language: Go
- Homepage: https://wingk-wong.blogspot.com/2020/03/building-serverless-crud-services-in-go.html
- Size: 36.1 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# serverless-iam-dynamodb
Building serverless CRUD services in Go with DynamoDB
## Project structure
/.serverless
It will be created automatically when running ``serverless deploy`` in where deployment zip files, cloudformation stack files will be generated
/bin
This is the folder where our built Go codes are placed
/scripts
General scripts for building Go codes and deployment
/src/handlers
All Lambda handlers will be placed here
/src/utils
General functions go here
## Prerequisites
Install serverless cli
```
npm install -g serverless
```
Install aws cli
```
pip install awscli
```
Setup your aws credentials
```
aws configure
```
Of course you need to install [Go](https://golang.org/doc/install)
## Getting started
> By default, a custom authorizer has been enabled for ``create``, ``list``, ``update``, ``delete`` and ``get``. Please replace ```` with your JWT Secret Key in serverless.yml (Line 35).
### Building the code
This script compiles functions to ``bin/handlers/``.
```
./scripts/build.sh
```
### Deploying to AWS
This script includes the build script and triggers serverless deploy, which will create/update a single CloudFormation stack to provision/update corresponding resources.
```
./scripts/deploy.sh
```
You should see something like
```bash
************************************************
* Building ...
************************************************
************************************************
* Compiling functions to bin/handlers/ ...
************************************************
* Compiled authHandler
* Compiled createHandler
* Compiled deleteHandler
* Compiled getHandler
* Compiled listHandler
* Compiled loginHandler
* Compiled updateHandler
************************************************
* Formatting Code ...
************************************************
createHandler.go
************************************************
* Build Completed
************************************************
************************************************
* Deploying ...
************************************************
Serverless: Packaging service...
Serverless: Excluding development dependencies...
Serverless: Excluding development dependencies...
Serverless: Excluding development dependencies...
Serverless: Excluding development dependencies...
Serverless: Excluding development dependencies...
Serverless: Excluding development dependencies...
Serverless: Excluding development dependencies...
Serverless: Uploading CloudFormation file to S3...
Serverless: Uploading artifacts...
Serverless: Uploading service auth.zip file to S3 (5.23 MB)...
Serverless: Uploading service list.zip file to S3 (7.2 MB)...
Serverless: Uploading service create.zip file to S3 (7.42 MB)...
Serverless: Uploading service get.zip file to S3 (7.2 MB)...
Serverless: Uploading service login.zip file to S3 (7.23 MB)...
Serverless: Uploading service delete.zip file to S3 (7.14 MB)...
Serverless: Uploading service update.zip file to S3 (7.45 MB)...
Serverless: Validating template...
Serverless: Updating Stack...
Serverless: Checking Stack update progress...
........................
Serverless: Stack update finished...
Service Information
service: serverless-iam-dynamodb
stage: dev
region: ap-southeast-1
stack: serverless-iam-dynamodb-dev
resources: 47
api keys:
None
endpoints:
GET - https://.execute-api.ap-southeast-1.amazonaws.com/dev/iam
POST - https://.execute-api.ap-southeast-1.amazonaws.com/dev/iam
PATCH - https://.execute-api.ap-southeast-1.amazonaws.com/dev/iam/{id}
DELETE - https://.execute-api.ap-southeast-1.amazonaws.com/dev/iam/{id}
POST - https://.execute-api.ap-southeast-1.amazonaws.com/dev/iam/login
GET - https://.execute-api.ap-southeast-1.amazonaws.com/dev/iam/{id}
functions:
auth: serverless-iam-dynamodb-dev-auth
list: serverless-iam-dynamodb-dev-list
create: serverless-iam-dynamodb-dev-create
update: serverless-iam-dynamodb-dev-update
delete: serverless-iam-dynamodb-dev-delete
login: serverless-iam-dynamodb-dev-login
get: serverless-iam-dynamodb-dev-get
layers:
None
Serverless: Removing old service artifacts from S3...
Serverless: Run the "serverless" command to setup monitoring, troubleshooting and testing
```