-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathServerless_Notes.txt
More file actions
114 lines (94 loc) · 3.64 KB
/
Serverless_Notes.txt
File metadata and controls
114 lines (94 loc) · 3.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
----------
Serverless
----------
# create an account
- https://dashboard.serverless.com
# Open CLI and install
$ npm install --global|-g serverless
# Login to your account:
$ serverless login
# Start your new project:
$ serverless
# Update
$ npm i serverless
# More info
- https://serverless.com/framework/docs/
# Working with projects/services
# Create a project
$ sls create -t aws-nodejs -p hello-world
# Test with:
# Lambda Functions:
$ sls invoke [local] -f FUNCTION_NAME [-d '{"Key": "Val"}']
# APIs (requires: `serverless-offline` plugin):
$ npm install serverless-offline --save-dev (one-time)
$ sls offline
# Deploy with:
$ sls deploy [-s stage] [-r region] [-f function] [-v]
# Remove with:
$ sls remove [-s stage]
# View Logs with:
$ sls logs -f FUNCTION [--startTime 5m] [-t | --tail]
# Get info (including API endpoints) [and CloudFormation Stack Outputs]
$ sls info [-v]
# Get deploy info
$ sls deploy list
# Get deployed lambda functions info
$ sls deploy list functions
# prune some lambdas
$ sls prune -i -n N --stage STAGE --region REGION
Plugins
-------
- serverless-offline
- test API gateways locally
- serverless-pseudo-parameters
- use CloudFormation pseudo parameters
- serverless-aws-documentation
- create/use API documenatation/models
- serverless-python-requirements
- grabs all Pipfile requirements and packages up for deployment
- use instead of Lambda layers
- cannot edit/view lambda functions in-line (AWS console)
- Check out the `AwsRollbackFunction` plugin [built-in?] for deployment rollback functionality
- Check out the `serverless-layers` (or similar) plugin(s) for managing lambda layers
- serverless-prune-plugin
custom:
prune:
automatic: true
includeLayers: true
number: 3
```
# Install plugins:
# (option A): two steps
# 1. install the plugin
$ npm install --save-dev PLUGIN
# 2. add to "plugins section" in the `serverless.yaml` file, e.g.
plugins:
- PLUGIN
# (option B): one step (installs and lists in the `serverless.yaml` "plugins section")
# (this method removes any comments within the plugins section)
$ sls plugin install -n PLUGIN
```
Question and TODO
--------------------
- how to create/use lambda functions aliases?
General Observations
--------------------
- Serverless deploys new versions of lambda functions, layers and re-deploys the API stage for every deployment (`sls deploy`)
- a `sls deploy` deploys all functions, hence creating a new version of the lambda (unless you specify the `-f` option to only deploy one functon)
(`cloudformation package` would only upload/update functions that change)
- `sls deploy` results displays API endpoint(s)/method(s) created
- default lambda memory/timeout settings: 1024MB/6 seconds (override in provider/functions)
- Lambda's tagged with key ’STAGE’ automatically set to the stage
- api endpoint not changing
- vpc settings are hard-coded (but shouldn’t/wouldn’t change much) (maybe create a plugin)
- local lambda and api testing
- can see CW logs from cli
- can’t remove single/specific function
- API IDs/endpoints don't change with subsequent deploys
- Lambda ARNs and API IDs do not change for each serverless deployment
- don't think you can set lambda aliases natively without a plugin
- you can not define/use models or docs without a plugin
- Doesn't appear to be a way to use encrypted lambda environment variables with CloudFormation or Serverless
- Serverless documentation/models plugin - can't use the pre-existing "Empty" API model, had to create a new
- Serverless documentation/models plugin - models are created as one-liners as viewed in the AWS console
tags: serverless, sls