Name: workshops
Owner: Serverless
Description: Companion repo for workshops with instructions and code examples
Created: 2017-10-27 18:18:12.0
Updated: 2018-01-24 12:20:36.0
Pushed: 2017-11-17 18:08:25.0
Size: 11
Language: JavaScript
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
A companion repository for workshops with instructions and code examples.
https://drive.google.com/file/d/13D6U2yMwDrg5BJQQPVx_CG2AdF5dA_CV/view?usp=sharing
These steps need to be completed before the workshop:
Download appropriate OS package and install it on your machine.
Test to see that you have npm
and node
installed properly:
m -v
de -v
Download appropriate OS package and install it on your machine.
Test to see that you have git
installed properly:
t version
Download appropriate OS package and install it on your machine.
Test to see that you have curl
installed properly:
rl --version
m install -g serverless
Test to see that you have Serverless Framework installed properly:
rverless version
Follow instructions in the tutorial to:
Note: Each workshop participant needs to setup their own AWS account.
As part of the workshop, we will do the following exercises.
Create the app from scratch:
<user_folder>
rverless create --template hello-world --path hello-sls
s deploy
Open the handler.js
file in your text editor and update it with the following code:
strict';
le.exports.helloWorld = (event, context, callback) => {
t dynamicMsg = 'Hello Unknown!';
check for GET params and use if available
(event.queryStringParameters && event.queryStringParameters.name) {
dynamicMsg = `Hello ${event.queryStringParameters.name}!`;
nst response = {
statusCode: 200,
headers: {
'Access-Control-Allow-Origin': '*', // Required for CORS support to work
},
body: JSON.stringify({
// message: 'Go Serverless v1.0! Your function executed successfully!',
message: dynamicMsg,
input: event,
}),
llback(null, response);
Then, deploy the new code changes:
s deploy
Let's install the users-service
project from the Github repo:
d into your working folder
<user_folder>
nstall the project
s install --url https://github.com/serverless/workshops/tree/master/labs/users-service
d into the users-service folder
users-service
Then, deploy the new project:
s deploy
Note: We need to fetch the urls for the deployed endpoints, and replace the urls in the following code fragments, before we run them.
s info
Go to the browser and type in the url:
https://XXXXXXXXXX.execute-api.us-east-1.amazonaws.com/dev/users/1
Or you can curl
it on the command line:
rl -v -X GET https://XXXXXXXXXX.execute-api.us-east-1.amazonaws.com/dev/users/1
rl -v -X POST \
https://XXXXXXXXXX.execute-api.us-east-1.amazonaws.com/dev/users/create \
-d '{"user": {"name":"John Doe", "email":"john.doe@email.com"}}'
rl -v -X DELETE https://XXXXXXXXXX.execute-api.us-east-1.amazonaws.com/dev/users/1
s info
Let's simulate an error and see it in the logs.
Tail the log for errors:
<user_folder>/users-service
s logs -f get -t
Go to the browser and type in the url:
https://XXXXXXXXXX.execute-api.us-east-1.amazonaws.com/dev/users/999
Or you can curl
it on the command line:
rl -v -X GET https://XXXXXXXXXX.execute-api.us-east-1.amazonaws.com/dev/users/999
s metrics
s invoke local -f get -p \
users/test/event.get.json
s invoke -f get -p \
users/test/event.get.json --log