You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add example scripts and docs for Serverless Framework (#113)
* Add example scripts and docs for Serverless Framework
* Refactor Examples folder and scripts
- Add a common config.sh script
- Move SAM templates to scripts/SAM
- Add Serverless templates to scripts/serverless
- Update the scripts to work with new folder structure and config.sh
cd swift-aws-lambda-runtime/Examples/LambdaFunctions
12
+
```
13
+
7
14
Note: The example scripts assume you have [jq](https://stedolan.github.io/jq/download/) command line tool installed.
8
15
9
16
## Deployment instructions using AWS CLI
@@ -85,3 +92,86 @@ The SAM template will provide an output labelled `LambdaApiGatewayEndpoint` whic
85
92
***Warning:*** This SAM template is only intended as a sample and creates a publicly accessible HTTP endpoint.
86
93
87
94
For all other samples use the AWS Lambda console.
95
+
96
+
### Deployment instructions using Serverless Framework (serverless.com)
97
+
98
+
[Serverless framework](https://www.serverless.com/open-source/) (Serverless) is a provider agnostic, open-source framework for building serverless applications. This framework allows you to easily deploy other AWS resources and more complex deployment mechanisms such a CI pipelines. Serverless Framework offers solutions for not only deploying but also testing, monitoring, alerting, and security and is widely adopted by the industry and offers along the open-source version a paid one.
99
+
100
+
***Note:*** Deploying using Serverless will automatically create resources within your AWS account. Charges may apply for these resources.
101
+
102
+
To use Serverless to deploy this sample to AWS:
103
+
104
+
1. Install the AWS CLI by following the [instructions](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html).
105
+
106
+
2. Install Serverless by following the [instructions](https://www.serverless.com/framework/docs/getting-started/).
107
+
If you already have installed be sure you have the latest version.
108
+
The examples have been tested with the version 1.72.0.
109
+
110
+
```
111
+
Serverless --version
112
+
Framework Core: 1.72.0 (standalone)
113
+
Plugin: 3.6.13
114
+
SDK: 2.3.1
115
+
Components: 2.30.12
116
+
```
117
+
118
+
3. Build, package and deploy the Lambda
119
+
120
+
```
121
+
./scripts/serverless-deploy.sh
122
+
```
123
+
124
+
The script will ask you which sample Lambda you wish to deploy.
125
+
126
+
The `serverless-deploy.sh` script passes through any parameters to the Serverless deploy command.
127
+
128
+
4. Testing
129
+
130
+
For the APIGateway sample:
131
+
132
+
The Serverless template will provide an endpoint which you can use to test the Lambda.
133
+
134
+
Outuput example:
135
+
136
+
```
137
+
...
138
+
...
139
+
Serverless: Stack update finished...
140
+
Service Information
141
+
service: apigateway-swift-aws
142
+
stage: dev
143
+
region: us-east-1
144
+
stack: apigateway-swift-aws-dev
145
+
resources: 12
146
+
api keys:
147
+
None
148
+
endpoints:
149
+
GET - https://r39lvhfng3.execute-api.us-east-1.amazonaws.com/api
0 commit comments