https://github.com/sc5/serverless-blog-workshop
AWS -Serverless Blog Workshop
https://github.com/sc5/serverless-blog-workshop
Last synced: 10 months ago
JSON representation
AWS -Serverless Blog Workshop
- Host: GitHub
- URL: https://github.com/sc5/serverless-blog-workshop
- Owner: SC5
- License: mit
- Created: 2016-02-29T06:57:11.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2017-01-10T09:43:48.000Z (over 9 years ago)
- Last Synced: 2025-05-07T05:28:22.551Z (about 1 year ago)
- Language: JavaScript
- Homepage: http://www.sc5.io
- Size: 70.3 KB
- Stars: 13
- Watchers: 18
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Serverless Blog Workshop by SC5
Example backend project for AWS - Serverless hackathon.
Project is compatible with Serverless v1
## Step by step instructions for building the project with Serverless Framework v1.5
### Setup project
* Create the service from the `sc5-serverless-boilerplate`
```bash
> sls install -u https://github.com/SC5/sc5-serverless-boilerplate -n serverless-blog
> cd serverless-blog
> npm install
```
### Set up storage (DynamoDB)
* Un-comment `Resources:` and `resources:` in `serverless.yml`.
```
# DynamoDB Blog table for workshop
BlogTable:
Type: AWS::DynamoDB::Table
DeletionPolicy: Retain
Properties:
AttributeDefinitions:
- AttributeName: id
AttributeType: S
KeySchema:
- AttributeName: id
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
TableName: ${self:provider.environment.TABLE_NAME}
```
### Create function and endpoints
* Create the function
```bash
sls create function -f posts --handler posts/index.handler
```
* Register HTTP endpoints by adding the following to the function definition in `serverless.yml`
```
events:
- http:
path: posts
method: get
cors: true
integration: lambda
- http:
path: posts
method: posts
cors: true
integration: lambda
- http:
path: posts/{id}
method: put
cors: true
integration: lambda
- http:
path: posts/{id}
method: delete
cors: true
integration: lambda
```
### Implement the functionality
* Copy `posts/index.js` and `posts/BlogStorage.js` from this repo to your service (`posts` folder)
### Deploy and test
* Deploy the resources (and functions) using
```
sls deploy
````
* Copy tests from `test/posts.js` in this repo to your service
* Run `serveless-mocha-plugin` tests
```
sls invoke test --region us-east-1 --stage dev
```
### Set up your blog application
* Launch the blog application
* Enter the service Url (https://..../posts). The service URL can be retrieved using
```
sls info
```
#### Enjoy, your ready to go!
# Feedback
mikael.puittinen@sc5.io