반응형
기초사용법
정의
서버리스 프로그램을 편하게 할 수 있도록 도와주는 Framework (Node.js 기반)
경쟁제품 : Python 기반의 Zappa, AWS 의 SAM 이 있다
Serverless Framework 는 경쟁제품보다 오래 되어 사용처가 많고, 커뮤니티도 활발하다
지원하는 Cloud 밴더로 다양하다
sls create --help
설치
#Step 1. Install serverless globally
npm install serverless -g
#Step 2. Create a serverless function
serverless create --template aws-nodejs --path my-service
cd my-service
#Step 3. Deploy to cloud provider
serverless deploy -v
#Step 4-1. Invoke the Function on cloud provider
serverless invoke -f hello -l
#Step 4-2. Invoke the Function on your local machine
serverless invoke local -f hello -l
#Step 5. Fetch the Function Logs
serverless logs -f hello -t
#Step 6. Remove the Service
serverless remove
Boilerplate
동일한 repository 에서 server 와 client 배포 하는 방법
tree 구조
samplefolder
│ package.json
│ serverless.yml
│
├─client
│ │ babel.config.js
│ │ package.json
│ │ vue.config.js
│ │
│ ├─public
│ └─src
└─server
│ .eslintrc.js
│ package.json
│
└─src
root 의 package.json
"devDependencies": {
"serverless-apig-s3": "^2.0.0"
},
"scripts": {
"package:server": "serverless package --stage production",
"deploy:server": "serverless deploy --stage production",
"deploy:client": "cd client && npm run build && cd .. && serverless client deploy --stage production",
"postinstall": "cd client && npm install && cd .. && cd server && npm install && cd .."
},
root 의 serverless.yml
package:
exclude:
# Exclude everything!
- "*/**"
include:
# Source files
- "server/src/rest/**"
- "server/src/utils/**"
# Dependencies bcryptjs + jsonwebtoken
- "server/node_modules/bcryptjs/**"
- "server/node_modules/buffer-equal-constant-time/**"
- "server/node_modules/ecdsa-sig-formatter/**"
- "server/node_modules/jsonwebtoken/**"
- "server/node_modules/jwa/**"
- "server/node_modules/jws/**"
- "server/node_modules/lodash*/**"
- "server/node_modules/ms/**"
- "server/node_modules/safe-buffer/**"
참조포스트
Uploaded by N2T
반응형
'AWS' 카테고리의 다른 글
AWS DynamoDB 참고사이트 (0) | 2022.08.26 |
---|---|
AWS를 도커로 설정하기 (0) | 2022.08.26 |
puppeteer + lambda 조합으로 사용법 (0) | 2022.08.26 |
IAM 정책 (0) | 2022.08.24 |
Underneath DynamoDB (0) | 2022.08.24 |
CodeCommit (0) | 2022.08.24 |
DynamoDB (0) | 2022.08.24 |
API authorizers (0) | 2022.08.24 |