{"id":13812859,"url":"https://github.com/novemberde/serverless-crawler-demo","last_synced_at":"2025-07-21T03:31:43.108Z","repository":{"id":89448176,"uuid":"138269372","full_name":"novemberde/serverless-crawler-demo","owner":"novemberde","description":"Serverless Architecture Crawler demo","archived":false,"fork":false,"pushed_at":"2020-05-13T21:31:47.000Z","size":999,"stargazers_count":26,"open_issues_count":4,"forks_count":8,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-22T16:43:11.912Z","etag":null,"topics":["aws","crawler","demo","handson","serverless"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/novemberde.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2018-06-22T07:21:03.000Z","updated_at":"2023-07-28T17:40:29.000Z","dependencies_parsed_at":"2024-01-13T15:37:27.914Z","dependency_job_id":null,"html_url":"https://github.com/novemberde/serverless-crawler-demo","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/novemberde/serverless-crawler-demo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/novemberde%2Fserverless-crawler-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/novemberde%2Fserverless-crawler-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/novemberde%2Fserverless-crawler-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/novemberde%2Fserverless-crawler-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/novemberde","download_url":"https://codeload.github.com/novemberde/serverless-crawler-demo/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/novemberde%2Fserverless-crawler-demo/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266235280,"owners_count":23897175,"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":["aws","crawler","demo","handson","serverless"],"created_at":"2024-08-04T04:00:56.718Z","updated_at":"2025-07-21T03:31:43.059Z","avatar_url":"https://github.com/novemberde.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# Serverless Group First Hands-on Part 2\n\nAWSKRUG Serverless Group의 첫번째 핸즈온 Part.2 웹크롤러 만들기입니다.😁\n\n[Part.1](https://github.com/novemberde/serverless-todo-demo)을 하셨다면 \"Cloud9 시작하기\", \"Serverless Framework 소개\", 그리고 \"S3 bucket 생성하기\"는 넘어가도 좋습니다.\n\n## Objective\n\nAmazon Web Service 를 활용하여 Serverless architecture로 웹크롤러를 배포합니다.\n크롤링된 데이터는 DynamoDB에 저장합니다.\n\n## AWS Resources\n\nAWS에서 사용하는 리소스는 다음과 같습니다.\n\n- Cloud9: 코드 작성, 실행 및 디버깅을 위한 클라우드 기반 IDE.\n- Lambda: 서버를 프로비저닝하거나 관리하지 않고도 코드를 실행할 수 있게 해주는 컴퓨팅 서비스. 서버리스 아키텍쳐의 핵심 서비스.\n- DynamoDB: 완벽하게 관리되는 NoSQL 데이터베이스 서비스로, 원활한 확장성과 함께 빠르고 예측 가능한 성능을 제공.\n\n## Cloud 9 시작하기\n\nCloud9 은 하나의 IDE입니다. 그렇지만 이전의 설치형 IDE와는 다릅니다. 설치형 IDE는 로컬 PC에 프로그램을 설치하던가\n실행하는 방식이었다면, Cloud9은 브라우저가 실행가능한 모든 OS에서 사용이 가능합니다.\n\n맨 처음 Cloud9은 AWS 내에서가 아닌 별도의 서비스로 제공되었습니다. AWS에 인수된 이후 Cloud9은 AWS의 Managed Service형태로 바뀌었고,\nAWS의 서비스와 결합하여 사용이 가능해졌습니다. 코드 편집과 명령줄 지원 등의 평범한 IDE 기능을 지니고 있던 반면에, 현재는 AWS 서비스와\n결합되어 직접 Lambda 코드를 배포하던가, 실제로 Cloud9이 실행되고 있는 EC2의 컴퓨팅 성능을 향상시켜서\n로컬 PC의 사양에 종속되지 않은 개발을 할 수가 있습니다.\n\n그러면 Cloud9 환경을 시작해봅시다.\n\n[Cloud 9 Console](https://ap-southeast-1.console.aws.amazon.com/cloud9/home?region=ap-southeast-1#)에 접속합니다.\n\n아래와 같은 화면에서 [Create Environment](https://ap-southeast-1.console.aws.amazon.com/cloud9/home/create) 버튼을 누릅니다.\n\n![c9-create](/images/c9-create.png)\n\nName과 Description을 다음과 같이 입력합니다.\n\n- Name: ServerlessHandsOn\n- Description: Serverless hands-on in AWSKRUG Serverless Group\n\n![c9-create-name](/images/c9-create-name.png)\n\nConfigure Setting은 다음과 같이 합니다.\n\n- Environment Type: EC2\n- Instance Type: T2.micro\n- Cost Save Setting: After 30 minutes\n- Network Settings: Default\n\n![c9-conf](/images/c9-conf.png)\n\n모든 설정을 마쳤다면 Cloud9 Environment를 생성하고 Open IDE를 통해 개발 환경에 접속합니다.\n\n접속하면 다음과 같은 화면을 볼 수 있습니다.\n\n1. 현재 Environment name\n2. EC2에서 명령어를 입력할 수 있는 Terminal\n3. Lambda Functions\n    - Local Functions: 배포되지 않은 편집중인 Functions\n    - Remote Functions: 현재 설정해놓은 Region에 배포된 Lambda Functions\n4. Preferences\n\n![c9-env](/images/c9-env.png)\n\n현재 ap-southeast-1 region에 Cloud9 Environment를 배포했으므로 Default Region이 ap-southeast-1으로 되어 있습니다.\nPreferences(설정 화면)에서 ap-northeast-2(Seoul Region)으로 바꾸어줍니다.\n\n- Preferences \u003e AWS Settings \u003e Region \u003e Asia Pacific(Seoul)\n\n![c9-region](/images/c9-region.png)\n\n설정을 마친 다음 Node.js 버전을 올려야합니다.\n현재(2018-06-30) 제공하는 node의 버전이 6.10이기 때문입니다.\n보통은 nvm을 따로 설치해야하지만 Cloud9을 사용하면 별도의 nvm 설치는 필요없습니다.\n다음의 명령어를 terminal에 입력하여 node의 버전을 8.10으로 설정합니다.\n\n```sh\n$ sudo yum groupinstall 'Development Tools'\n$ nvm install 8.10\nDownloading https://nodejs.org/dist/v8.10.0/node-v8.10.0-linux-x64.tar.xz...\n######################################################################## 100.0%\nNow using node v8.10.0 (npm v5.6.0)\n\n# 8.10을 default로 사용하기\n$ nvm alias default 8.10\n```\n\nCloud9 설정을 완료하였습니다.\n\n## [Serverless Framework](https://serverless.com/)\n\n![serverless framework main](/images/serverless-framework-1.png)\n\nServerless Framework 메인에 나와있는 소개문구는 다음과 같습니다.\n\nServerless is your toolkit for deploying and operating serverless architectures.\nFocus on your application, not your infrastructure.\n\n위 내용을 번역한 내용은 \"Serverless는 서버 없는 아키텍처를 배치하고 운영하기 위한 툴킷입니다. 인프라가 아닌 애플리케이션에 집중합니다.\" 입니다.\n이처럼 Serverless framework는 Serverless architecture를 운영하기 위한 툴이라고 생각하면 됩니다.\n\n그러면 serverless framework를 사용하기 위한 환경은 어떻게 될까요?\n\nnode.js가 설치되어 있는 환경에서 사용할 수 있습니다.\n\nopen source로 기여하고 싶다면 [https://github.com/serverless/serverless](https://github.com/serverless/serverless)에서 issue와 pull request를 등록해주세요.\n\n### Serverless Framework 살펴보기\n\nServerless Framework를 사용하기 위해서 명령어들을 살펴봅시다.\n\n```sh\n# Serverless Framework를 설치합니다.\n$ npm i -g serverless\n\n# 명령어들을 확인해봅니다.\n$ serverless --help\n\nCommands\n* You can run commands with \"serverless\" or the shortcut \"sls\"\n* Pass \"--verbose\" to this command to get in-depth plugin info\n* Pass \"--no-color\" to disable CLI colors\n* Pass \"--help\" after any \u003ccommand\u003e for contextual help\n\nFramework\n* Documentation: https://serverless.com/framework/docs/\n\nconfig ........................ Configure Serverless\nconfig credentials ............ Configures a new provider profile for the Serverless Framework\ncreate ........................ Create new Serverless service\ndeploy ........................ Deploy a Serverless service\ndeploy function ............... Deploy a single function from the service\ndeploy list ................... List deployed version of your Serverless Service\ndeploy list functions ......... List all the deployed functions and their versions\ninfo .......................... Display information about the service\ninstall ....................... Install a Serverless service from GitHub or a plugin from the Serverless registry\ninvoke ........................ Invoke a deployed function\ninvoke local .................. Invoke function locally\nlogs .......................... Output the logs of a deployed function\nmetrics ....................... Show metrics for a specific function\npackage ....................... Packages a Serverless service\nplugin ........................ Plugin management for Serverless\nplugin install ................ Install and add a plugin to your service\nplugin uninstall .............. Uninstall and remove a plugin from your service\nplugin list ................... Lists all available plugins\nplugin search ................. Search for plugins\nprint ......................... Print your compiled and resolved config file\nremove ........................ Remove Serverless service and all resources\nrollback ...................... Rollback the Serverless service to a specific deployment\nrollback function ............. Rollback the function to the previous version\nslstats ....................... Enable or disable stats\n\nPlatform (Beta)\n* The Serverless Platform is currently in experimental beta. Follow the docs below to get started.\n* Documentation: https://serverless.com/platform/docs/\n\nemit .......................... Emits an event to a running Event Gateway\nlogin ......................... Login or sign up for the Serverless Platform\nlogout ........................ Logout from the Serverless Platform\nrun ........................... Runs the Event Gateway and the Emulator\n\nPlugins\nAwsConfigCredentials, Config, Create, Deploy, Emit, Info, Install, Invoke, Login, Logout, Logs, Metrics, Package, Plugin, PluginInstall, PluginList, PluginSearch, PluginUninstall, Print, Remove, Rollback, Run, SlStats\n```\n\n여기서 자주 사용하게 될 명령어는 다음과 같습니다.\n\n- create: 프로젝트 생성시 사용\n- deploy: 배포할 때 사용\n- package: 배포될 패키지의 구조를 보고싶을 때 사용\n- invoke: 특정 handler를 동작시킬 때 사용\n- remove: 배포된 리소스를 제거할 때 사용\n\n간단하게 로컬에서 serverless 명령어를 테스트해봅니다. deploy 명령어는 추후에 사용하겠습니다.\n\n```sh\n# Global 로 serverless framework 설치\n$ npm i -g serverless\n\n# serverless service 생성 힌트 받기\n$ serverless create --help\nPlugin: Create\ncreate ........................ Create new Serverless service\n    --template / -t .................... Template for the service. Available templates: \"aws-nodejs\", \"aws-nodejs-typescript\", \"aws-nodejs-ecma-script\", \"aws-python\", \"aws-python3\", \"aws-groovy-gradle\", \"aws-java-maven\", \"aws-java-gradle\", \"aws-kotlin-jvm-maven\", \"aws-kotlin-jvm-gradle\", \"aws-kotlin-nodejs-gradle\", \"aws-scala-sbt\", \"aws-csharp\", \"aws-fsharp\", \"aws-go\", \"aws-go-dep\", \"azure-nodejs\", \"fn-nodejs\", \"fn-go\", \"google-nodejs\", \"kubeless-python\", \"kubeless-nodejs\", \"openwhisk-java-maven\", \"openwhisk-nodejs\", \"openwhisk-php\", \"openwhisk-python\", \"openwhisk-swift\", \"spotinst-nodejs\", \"spotinst-python\", \"spotinst-ruby\", \"spotinst-java8\", \"webtasks-nodejs\", \"plugin\" and \"hello-world\"\n    --template-url / -u ................ Template URL for the service. Supports: GitHub, BitBucket\n    --template-path .................... Template local path for the service.\n    --path / -p ........................ The path where the service should be created (e.g. --path my-service)\n    --name / -n ........................ Name for the service. Overwrites the default name of the created service. ## \"\n\n# node를 사용하므로 템플릿을 \"aws-nodejs\" 로 \"sample-app\" 생성하기\n$ serverless create -t \"aws-nodejs\" -p sample-app\n\n# sample-app에서 명령어 연습하기\n$ cd sample-app\n~/sample-app $ serverless package\nServerless: Packaging service...\nServerless: Excluding development dependencies...\n\n# 여기까지 진행했다면 .serverless 디렉터리를 확인할 수 있습니다.\n~/sample-app $ cd .serverless\n\n# 생성된 파일을 보면 다음과 같음을 알 수 있습니다.\n~/sample-app/.serverless $ ls\ncloudformation-template-create-stack.json\ncloudformation-template-update-stack.json\nsample-app.zip\nserverless-state.json\n```\n\n위에 생성된 파일이 어떻게 동작하는지는 파일명만으로도 유추할 수 있습니다.\n\n현재 cloudformation에 stack이 존재하지 않을 경우 스택을 생성한 다음,\n업데이트를 하여 원하는 코드가 Lambda에 배포되도록 하는 것입니다.\n\nserverless-state.json파일은 해당 버전의 serverless application에 대한\n정보가 담겨 있습니다.\n\n```sh\n# 다시 앱의 루트디렉터리로 돌와와서 invoke를 해보겠습니다.\n~/sample-app/.serverless $ cd ..\n~/sample-app $ serverless invoke local --function hello\n{\n    \"statusCode\": 200,\n    \"body\": \"{\\\"message\\\":\\\"Go Serverless v1.0! Your function executed successfully!\\\",\\\"input\\\":\\\"\\\"}\"\n}\n```\n\n## S3 Bucket 생성하기\n\nS3는 Object Storage로 쉽게 설명하자면 하나의 저장소입니다. 파일들을 업로드 / 다운로드 할 수 있으며 AWS에서 핵심적인 서비스 중 하나입니다.\n여러 방면으로 활용할 수 있지만 여기서는 소스코드의 저장소 역할을 합니다.\n\nS3의 메인으로 가서 버킷 생성하기 버튼을 클릭합니다.\n\n![s3-create-btn.png](/images/s3-create-btn.png)\n\n아래와 같이 입력하고 생성버튼을 클릭합니다.\n\n- 버킷 이름(Bucket name): USERNAME-serverless-hands-on-1   // 여기서 USERNAME을 수정합니다. ex) khbyun-serverless-hands-on-1\n- 리전(Region): 아시아 태평양(서울)\n\n![s3-create-btn.png](/images/s3-create-1.png)\n\n## Node.js로 크롤링 시작하기\n\n파일 트리는 다음과 같습니다.\n\n```txt\nenvironment\n└── serverless-crawler  : Crawler\n    ├── handler.js  : Lambda에서 trigger하기 위한 handler\n    ├── handler.test.js  : Local에서 handler를 trigger하기 위한 스크립트\n    ├── config.yml : serverless.yml에서 사용하기 위한 변수\n    ├── package.json\n    └── serverless.yml : Serverless Framework config file\n```\n\n먼저 터미널을 열어 serverless-crawler 디렉터리를 생성하고 npm 초기화를 시켜줍니다.\n\n```sh\nec2-user:~/ $ cd ~/environment\nec2-user:~/environment $ mkdir serverless-crawler \u0026\u0026 cd ec2-user:~/environment/serverless-crawler $ npm init -y\n```\n\n필요한 npm module들을 install합니다. \n여기서 aws-sdk는 개발을 위해 설치합니다. \nLambda는 aws-sdk를 기본적으로 포함하고 있기 때문에 실제로 배포할 때는 포함시키지 않아야합니다. \ndev-dependency로 넣어두면 배포할 때 제외됩니다.\n\n- Dependencies\n  - cheerio : HTML페이지를 파싱하고, 결과 데이터를 수집하기 위한 API를 제공\n  \u003c!-- - puppeteer : DevTools Protocol을 통해 헤드가 없는 Chrome또는 Chromium을 제어하는 고급 API를 제공 --\u003e\n  - got : 몇 MB에 불과한 http 요청을 간단하게 하는 API 제공\n  - dynamoose : DynamoDB를 사용하기 쉽도록 Modeling하는 도구\n- Dev-Dependencies\n  - aws-sdk : AWS 리소스를 사용하기 위한 SDK\n  - serverless : Serverless Framework\n\n```sh\n$ npm i -S cheerio got dynamoose\n$ npm i -D aws-sdk serverless\n```\n\n각 파일을 편집합니다.\n\n### serverless-crawler/config.yml\n\n```yml\nAWS_REGION: ap-northeast-2\nSTAGE: dev\nDEPLOYMENT_BUCKET: USERNAME-serverless-hands-on-1    # USERNAME 수정 필요!\n```\n\n### serverless-crawler/handler.js\n\n```js\nconst got = require('got');\nconst cheerio = require('cheerio');\nconst dynamoose = require('dynamoose');\n\nrequire('aws-sdk').config.region = \"ap-northeast-2\";\n\nconst PortalKeyword = dynamoose.model('PortalKeyword', {\n    portal: {\n        type: String,\n        hashKey: true\n    },\n    createdAt: {\n        type: String,\n        rangeKey: true\n    },\n\tkeywords: {\n\t\ttype: Array\n\t}\n}, {\n    create: false, // Create a table if not exist,\n});\n\nexports.crawler = async function (event, context, callback) {\n\ttry {\n\t\tlet naverKeywords = [];\n\t\tlet daumKeywords = [];\n\n\t\tconst result = await Promise.all([\n\t\t\tgot('https://naver.com'),\n\t\t\tgot('http://daum.net'),\n\t\t]);\n\t\tconst createdAt = new Date().toISOString();\n\t\t\n\t\tconst naverContent = result[0].body;\n\t\tconst daumContent = result[1].body;\n\t\tconst $naver = cheerio.load(naverContent);\n\t\tconst $daum = cheerio.load(daumContent);\n\n\t\t// Get doms containing latest keywords\n\t\t$naver('.ah_l').filter((i, el) =\u003e {\n\t\t\treturn i===0;\n\t\t}).find('.ah_item').each(((i, el) =\u003e {\n\t\t\tif(i \u003e= 20) return;\n\t\t\tconst keyword = $naver(el).find('.ah_k').text();\n\t\t\tnaverKeywords.push({rank: i+1, keyword});\n\t\t}));\n\t\t$daum('.rank_cont').find('.link_issue[tabindex=-1]').each((i, el) =\u003e {\n\t\t\tconst keyword = $daum(el).text();\n\t\t\tdaumKeywords.push({rank: i+1, keyword});\n\t\t});\n\n\t\t// console.log({\n\t\t// \tnaver: naverKeywords,\n\t\t// \tdaum: daumKeywords,\n\t\t// });\n\n\t\tawait new PortalKeyword({\n\t\t\tportal: 'naver',\n\t\t\tcreatedAt,\n\t\t\tkeywords: naverKeywords\n\t\t}).save();\n\t\tawait new PortalKeyword({\n\t\t\tportal: 'daum',\n\t\t\tcreatedAt,\n\t\t\tkeywords: daumKeywords\n\t\t}).save();\n\n\t\treturn callback(null, \"success\");\n\t} catch (err) {\n\t\tcallback(err);\n\t}\n}\n```\n\n### serverless-crawler/handler.test.js\n\n```js\nconst crawler = require('./handler').crawler;\n\ncrawler({}, {}, (err, result) =\u003e {\n    if(err) return console.error(err);\n    console.log(result);\n});\n```\n\n### serverless-crawler/package.json\n\n```json\n...\n...\n  \"description\": \"AWSKRUG Serverless Group의 첫번째 핸즈온 Part.2 웹크롤러 만들기입니다.😁\",\n  \"main\": \"index.js\",\n  \"scripts\": {  // 이 부분을 추가합니다.\n    \"test\": \"node handler.test.js\", \n    \"deploy\": \"serverless deploy\"\n  },\n  \"repository\": {\n    \"type\": \"git\",\n    \"url\": \"git+https://github.com/novemberde/serverless-crawler-demo.git\"\n  },\n  \"keywords\": [],\n  \"author\": \"\",\n...\n```\n\n### serverless-crawler/serverless.yml\n\n```yml\nservice: ServerlessHandsOnPart2\n\nprovider:\n  name: aws\n  runtime: nodejs8.10\n  memorySize: 256\n  timeout: 30\n  stage:  ${file(./config.yml):STAGE}\n  region: ${file(./config.yml):AWS_REGION}\n  deploymentBucket: ${file(./config.yml):DEPLOYMENT_BUCKET}\n  environment:\n    NODE_ENV: production\n  iamRoleStatements:\n    - Effect: Allow\n      Action:\n        - dynamodb:DescribeTable\n        - dynamodb:Query\n        - dynamodb:Scan\n        - dynamodb:GetItem\n        - dynamodb:PutItem\n        - dynamodb:UpdateItem\n        - dynamodb:DeleteItem\n      Resource: \"arn:aws:dynamodb:${opt:region, self:provider.region}:*:*\"\n\nfunctions:\n  crawler:\n    handler: handler.crawler\n    events:\n      - schedule: rate(10 minutes)\n\n```\n\n## DynamoDB 테이블 생성하기\n\nDynamoDB를 설계할 시 주의해야할 점은 [FAQ](https://aws.amazon.com/ko/dynamodb/faqs/)를 참고하시길 바랍니다.\n\n이제 DynamoDB에 Todo table을 생성할 것입니다. 파티션 키와 정렬 키는 다음과 같이 설정합니다.\n\n- 파티션키(Partition Key): portal\n- 정렬키(Sort Key): createdAt\n\n그럼 [DynamoDB Console](https://ap-northeast-2.console.aws.amazon.com/dynamodb/home?region=ap-northeast-2#)로 이동합니다.\n테이블 만들기를 클릭하여 아래와 같이 테이블을 생성합니다.\n\n![dynamodb-create](/images/dynamodb-create.png)\n\n그런 다음에 다시 Cloud9으로 돌아가서 테스트 코드를 돌려봅니다.\n\n```sh\nec2-user:~/environment/serverless-crawler $ npm test\n\n\u003e serverless-crawler-demo@1.0.0 test/home/ec2-user/environment/serverless-crawler-demo\n\u003e node handler.test.js\n\nsuccess\n```\n\n[DynamoDB Console](https://ap-northeast-2.console.aws.amazon.com/dynamodb/home?region=ap-northeast-2#tables:selected=PortalKeyword)에 들어가서 성공적으로 항목들이 생성되었는지 확인합니다.\n\n## Cloud9에서 배포하기\n\n\u003c!-- Cloud9을 통한 배포는 크게 어렵지 않습니다. 다음과 같이 오른쪽 위치에 Local Functions가 있습니다.\n여기에는 편집하고 있는 serverlessHandsOn으로 나타날 것입니다.\n우클릭을 하고 Deploy를 클릭하면 배포가 완료됩니다.\n\n배포가 완료되면 Local Functions 아래에 Remote Functions에 해당 람다를 확인할 수 있습니다.\n\n![c9-deploy](/images/c9-deploy.png) --\u003e\nNode가 8.x버전이 설치되어 있으면 dev-dependency에 설치된 serverless 명령어를 바로 사용할 수 있습니다.\n만일 node 6.x버전이라면 Global로 serverless를 설치하여 줍니다. 현재는 8.x의 버전을 사용하기 때문에 다음 명령어는 넘어가겠습니다.\n\n```sh\nec2-user:~/environment/serverless-crawler (master) $ npm i -g serverless\n```\n\n설치가 완료되었으면 배포를 합니다. package.json에 script에 serverless deploy를 넣어 두었기 때문에\n다음과 같이 배포를 합니다.\n\n```sh\nec2-user:~/environment/serverless-crawler (master) $ npm run deploy\n\n\u003e serverless-crawler@1.0.0 deploy /home/ec2-user/environment/serverless-crawler\n\u003e serverless deploy\n\nServerless: Packaging service...\nServerless: Excluding development dependencies...\nServerless: Uploading CloudFormation file to S3...\nServerless: Uploading artifacts...\nServerless: Uploading service .zip file to S3 (8.69 MB)...\nServerless: Validating template...\nServerless: Creating Stack...\nServerless: Checking Stack create progress...\n....................\nServerless: Stack create finished...\nService Information\nservice: ServerlessHandsOnPart2\nstage: dev\nregion: ap-northeast-2\nstack: ServerlessHandsOnPart2-dev\napi keys:\n  None\nendpoints:\n  None\nfunctions:\n  crawler: ServerlessHandsOnPart2-dev-crawler\n```\n\n성공적으로 배포되었습니다.\n지금부터 주기적으로 DynamoDB에 검색어 랭킹이 쌓입니다.\n\n## 리소스 삭제하기\n\n서버리스 앱은 내리는 것이 어렵지 않습니다.\n간단한 Command 하나면 모든 스택이 내려갑니다.\nCloud9에서 새로운 터미널을 열고 다음과 같이 입력합니다.\n\n```sh\n$ cd ~/environment/serverless-crawler\n$ serverless remove\nServerless: Getting all objects in S3 bucket...\nServerless: Removing objects in S3 bucket...\nServerless: Removing Stack...\nServerless: Checking Stack removal progress...\n............\nServerless: Stack removal finished...\n```\n\n\n[DynamoDB Console](https://ap-northeast-2.console.aws.amazon.com/dynamodb/home?region=ap-northeast-2#)로 들어가서 Table을 삭제합니다. 리전은 서울입니다.\n\n[Cloud9 Console](https://ap-southeast-1.console.aws.amazon.com/cloud9/home?region=ap-southeast-1)로 들어가서 IDE를 삭제합니다. 리전은 싱가포르입니다.\n\n[S3 Console](https://s3.console.aws.amazon.com/s3/home?region=ap-southeast-1#)로 들어가서 생성된 버킷을 삭제합니다.\n\n## References\n\n- [https://aws.amazon.com/ko/cloud9/](https://aws.amazon.com/ko/cloud9/)\n- [https://serverless.com/](https://serverless.com/)\n- [https://www.npmjs.com/package/got](https://www.npmjs.com/package/got)\n- [https://www.npmjs.com/package/cheerio](https://www.npmjs.com/package/cheerio)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnovemberde%2Fserverless-crawler-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnovemberde%2Fserverless-crawler-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnovemberde%2Fserverless-crawler-demo/lists"}