https://github.com/johnf/serverless-cognito-demo
Serverless Cognito Demo
https://github.com/johnf/serverless-cognito-demo
Last synced: 8 months ago
JSON representation
Serverless Cognito Demo
- Host: GitHub
- URL: https://github.com/johnf/serverless-cognito-demo
- Owner: johnf
- Created: 2016-12-17T22:20:33.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-06-25T00:22:40.000Z (almost 9 years ago)
- Last Synced: 2025-03-18T07:12:15.195Z (about 1 year ago)
- Language: JavaScript
- Size: 231 KB
- Stars: 50
- Watchers: 6
- Forks: 8
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# NOTE: This was a demo for a pull request into serverless.
If you are wondering what you need to do client side, check out https://github.com/aws/amazon-cognito-identity-js
# Serverless Test
This testing assume that you have default AWS credentials set up in ~/.aws or
you are running on an EC2 instance with an EC2 role with the appropriate
permissions.
# Testing
## Create the pool
First you need to create a userpool
```
bin/create_user_pool
```
this will output the ARN
```
User Pool ARN is arn:aws:cognito-idp:us-east-1:123456789:userpool/us-east-1_XXXXXX
```
## Configure Serverless
Copy this ARN into `arn:` section of `serverless.yml`
Configure serverless to use your AWS credential.
## Bring up the stack
```
sls deploy
```
## Verify
* Browse to https://console.aws.amazon.com/apigateway/home?region=us-east-1#/apis
* Click on *dev-serverless-cognito-demo*
* Click on *Authorizers*
* You should see an authorizer configured as per 
* Click on *Resources*
* Click on */hello*
* You should see the method is protected by the cognito pool as per 
## Cleanup
Bring down the stack
```
sls remove
```
Delete the pool, you need to pass in the ID. The bit at the end of the ARN.
```
bin/delete_user_pool us-east-1_XX
```