{"id":19042483,"url":"https://github.com/serverless/workshops","last_synced_at":"2025-04-23T22:28:59.623Z","repository":{"id":65982507,"uuid":"108579879","full_name":"serverless/workshops","owner":"serverless","description":"Companion repo for workshops with instructions and code examples","archived":false,"fork":false,"pushed_at":"2017-11-17T18:08:25.000Z","size":11,"stargazers_count":5,"open_issues_count":0,"forks_count":5,"subscribers_count":29,"default_branch":"master","last_synced_at":"2025-04-18T07:51:35.928Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/serverless.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-10-27T18:18:12.000Z","updated_at":"2023-08-12T22:46:29.000Z","dependencies_parsed_at":"2023-02-19T18:25:20.240Z","dependency_job_id":null,"html_url":"https://github.com/serverless/workshops","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serverless%2Fworkshops","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serverless%2Fworkshops/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serverless%2Fworkshops/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serverless%2Fworkshops/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/serverless","download_url":"https://codeload.github.com/serverless/workshops/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250525846,"owners_count":21445085,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-08T22:37:59.442Z","updated_at":"2025-04-23T22:28:59.607Z","avatar_url":"https://github.com/serverless.png","language":"JavaScript","readme":"# Serverless Workshops\n\nA companion repository for workshops with instructions and code examples.\n\n## Slides\nhttps://drive.google.com/file/d/13D6U2yMwDrg5BJQQPVx_CG2AdF5dA_CV/view?usp=sharing\n\n## Pre-requisites\n\nThese steps need to be completed before the workshop:\n\n* Text editor installed\n* NPM and NodeJS 6.10 or later installed\n* Git 2.0.0 or later installed\n* Curl installed\n* Serverless Framework installed\n* AWS account setup \u0026 credentials configured\n\n### Install NPM and NodeJS\n\n[Download](https://nodejs.org/en/download/) appropriate OS package and install it on your machine.\n\nTest to see that you have `npm` and `node` installed properly:\n\n```\n$ npm -v\n$ node -v\n```\n\n### Install Git\n\n[Download](https://git-scm.com/downloads) appropriate OS package and install it on your machine.\n\nTest to see that you have `git` installed properly:\n\n```\n$ git version\n```\n\n### Install Curl\n\n[Download](https://curl.haxx.se/download.html) appropriate OS package and install it on your machine.\n\nTest to see that you have `curl` installed properly:\n\n```\n$ curl --version\n```\n\n### Install Serverless Framework\n\n```\n$ npm install -g serverless\n```\n\nTest to see that you have Serverless Framework installed properly:\n\n```\n$ serverless version\n```\n\n### AWS Setup\n\nFollow instructions in the [tutorial](https://serverless.com/provider-setup/#get-started) to:\n\n* Setup AWS account\n* Configured AWS credentials with the Serverless Framework\n\n**Note**: Each workshop participant needs to setup their own AWS account.\n\n## Labs Code Examples\n\nAs part of the workshop, we will do the following exercises.\n\n### Exercise 1: Hello World - creating the hello world app\n\nCreate the app from scratch:\n\n```\n$ cd \u003cuser_folder\u003e\n$ serverless create --template hello-world --path hello-sls\n$ sls deploy\n```\n\n### Exercise 2: Hello World - dynamic app\n\nOpen the `handler.js` file in your text editor and update it with the following code:\n\n```\n'use strict';\n\nmodule.exports.helloWorld = (event, context, callback) =\u003e {\n\n  let dynamicMsg = 'Hello Unknown!';\n\n  // check for GET params and use if available\n  if (event.queryStringParameters \u0026\u0026 event.queryStringParameters.name) {\n      dynamicMsg = `Hello ${event.queryStringParameters.name}!`;\n  }\n\n  const response = {\n    statusCode: 200,\n    headers: {\n      'Access-Control-Allow-Origin': '*', // Required for CORS support to work\n    },\n    body: JSON.stringify({\n      // message: 'Go Serverless v1.0! Your function executed successfully!',\n      message: dynamicMsg,\n      input: event,\n    }),\n  };\n\n  callback(null, response);\n};\n```\n\nThen, deploy the new code changes:\n\n```\n$ sls deploy\n```\n\n### Exercise 3: Users Service - install project\n\nLet's install the `users-service` project from the Github repo:\n\n```\n// cd into your working folder\n$ cd \u003cuser_folder\u003e\n\n// install the project\n$ sls install --url https://github.com/serverless/workshops/tree/master/labs/users-service\n\n// cd into the users-service folder\n$ cd users-service\n```\n\nThen, deploy the new project:\n\n```\n$ sls deploy\n```\n\n### Exercise 4: Users Service - calling the API\n\n**Note**: We need to fetch the urls for the deployed endpoints, and replace the urls in the following code fragments, before we run them.\n\n#### Fetch the urls for the endpoints\n\n```\n$ sls info\n```\n\n#### Get User\n\nGo to the browser and type in the url:\n\n`https://XXXXXXXXXX.execute-api.us-east-1.amazonaws.com/dev/users/1`\n\nOr you can `curl` it on the command line:\n\n```\n$ curl -v -X GET https://XXXXXXXXXX.execute-api.us-east-1.amazonaws.com/dev/users/1\n```\n\n#### Create User\n\n```\n$ curl -v -X POST \\\n       https://XXXXXXXXXX.execute-api.us-east-1.amazonaws.com/dev/users/create \\\n       -d '{\"user\": {\"name\":\"John Doe\", \"email\":\"john.doe@email.com\"}}'\n```\n\n#### Delete User\n\n```\n$ curl -v -X DELETE https://XXXXXXXXXX.execute-api.us-east-1.amazonaws.com/dev/users/1\n```\n\n### Exercise 5: Users Service - other CLI commands\n\n#### Fetch the project urls\n\n```\n$ sls info\n```\n\n#### Tailing logs\n\nLet's simulate an error and see it in the logs.\n\nTail the log for errors:\n\n```\n$ cd \u003cuser_folder\u003e/users-service\n\n$ sls logs -f get -t\n```\n\nGo to the browser and type in the url:\n\n`https://XXXXXXXXXX.execute-api.us-east-1.amazonaws.com/dev/users/999`\n\nOr you can `curl` it on the command line:\n\n```\n$ curl -v -X GET https://XXXXXXXXXX.execute-api.us-east-1.amazonaws.com/dev/users/999\n```\n\n#### Fetch the project metrics\n\n```\n$ sls metrics\n```\n\n#### Invoke a function locally\n\n```\n$ sls invoke local -f get -p \\\n       users/test/event.get.json\n```\n\n#### Invoke a function remotely\n\n```\n$ sls invoke -f get -p \\\n      users/test/event.get.json --log\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fserverless%2Fworkshops","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fserverless%2Fworkshops","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fserverless%2Fworkshops/lists"}