Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions aws-golang-simple-http-endpoint/serverless.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
service: aws-golang-simple-http-endpoint

frameworkVersion: ">=1.28.0 <2.0.0"
frameworkVersion: '2'

provider:
name: aws
Expand All @@ -10,14 +9,14 @@ functions:
hello:
handler: bin/hello
events:
- http:
path: hello
- httpApi:
path: /hello
method: get
world:
handler: bin/world
events:
- http:
path: world
- httpApi:
path: /world
method: get

package:
Expand Down
6 changes: 3 additions & 3 deletions aws-java-simple-http-endpoint/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ region: us-east-1
api keys:
None
endpoints:
GET - https://XXXXXXX.execute-api.us-east-1.amazonaws.com/dev/ping
GET - https://XXXXXXX.execute-api.us-east-1.amazonaws.com/ping
functions:
aws-java-simple-http-endpoint-dev-currentTime: arn:aws:lambda:us-east-1:XXXXXXX:function:aws-java-simple-http-endpoint-dev-currentTime

Expand Down Expand Up @@ -146,7 +146,7 @@ REPORT RequestId: XXXXXXX Duration: 0.51 ms Billed Duration: 100 ms Memory Size
Finally you can send an HTTP request directly to the endpoint using a tool like curl

```bash
curl https://XXXXXXX.execute-api.us-east-1.amazonaws.com/dev/ping
curl https://XXXXXXX.execute-api.us-east-1.amazonaws.com/ping
```

The expected result should be similar to:
Expand All @@ -157,4 +157,4 @@ The expected result should be similar to:

## Scaling

By default, AWS Lambda limits the total concurrent executions across all functions within a given region to 100. The default limit is a safety limit that protects you from costs due to potential runaway or recursive functions during initial development and testing. To increase this limit above the default, follow the steps in [To request a limit increase for concurrent executions](http://docs.aws.amazon.com/lambda/latest/dg/concurrent-executions.html#increase-concurrent-executions-limit).
By default, AWS Lambda limits the total concurrent executions across all functions within a given region to 1000. The default limit is a safety limit that protects you from costs due to potential runaway or recursive functions during initial development and testing. To increase this limit above the default, follow the steps in [To request a limit increase for concurrent executions](http://docs.aws.amazon.com/lambda/latest/dg/concurrent-executions.html#increase-concurrent-executions-limit).
9 changes: 4 additions & 5 deletions aws-java-simple-http-endpoint/serverless.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
service: aws-java-simple-http-endpoint

frameworkVersion: ">=1.2.0 <2.0.0"
frameworkVersion: '2'

provider:
name: aws
runtime: java8

package:
artifact: build/distributions/aws-java-simple-http-endpoint.zip

functions:
currentTime:
handler: com.serverless.Handler
events:
- http:
path: ping
- httpApi:
path: /ping
method: get
8 changes: 4 additions & 4 deletions aws-multiple-runtime/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ functions:
hello:
runtime: python3.6
events:
- http:
- httpApi:
method: get
path: greet
path: /greet
handler: web/handler.hello
time:
runtime: nodejs12.x
events:
- http:
- httpApi:
method: get
path: time
path: /time
handler: api/handler.timestamp
25 changes: 8 additions & 17 deletions aws-node-express-api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,19 @@ This template demonstrates how to develop and deploy a simple Node Express API s

## Anatomy of the template

This template configures a single function, `api`, which is responsible for handling all incoming requests thanks to configured `http` events. To learn more about `http` event configuration options, please refer to [http event docs](https://www.serverless.com/framework/docs/providers/aws/events/apigateway/). As the events are configured in a way to accept all incoming requests, `express` framework is responsible for routing and handling requests internally. Implementation takes advantage of `serverless-http` package, which allows you to wrap existing `express` applications. To learn more about `serverless-http`, please refer to corresponding [GitHub repository](https://github.com/dougmoscrop/serverless-http).
This template configures a single function, `api`, which is responsible for handling all incoming requests thanks to the `httpApi` event. To learn more about `httpApi` event configuration options, please refer to [httpApi event docs](https://www.serverless.com/framework/docs/providers/aws/events/http-api/). As the event is configured in a way to accept all incoming requests, `express` framework is responsible for routing and handling requests internally. Implementation takes advantage of `serverless-http` package, which allows you to wrap existing `express` applications. To learn more about `serverless-http`, please refer to corresponding [GitHub repository](https://github.com/dougmoscrop/serverless-http).

## Usage

### Deployment

This example is made to work with the Serverless Framework dashboard, which includes advanced features such as CI/CD, monitoring, metrics, etc.

In order to deploy with dashboard, you need to first login with:

```
serverless login
```

install dependencies with:
Install dependencies with:

```
npm install
```

and then perform deployment with:
and then deploy with:

```
serverless deploy
Expand Down Expand Up @@ -69,22 +61,21 @@ resources: 12
api keys:
None
endpoints:
ANY - https://xxxxxxx.execute-api.us-east-1.amazonaws.com/dev/
ANY - https://xxxxxxx.execute-api.us-east-1.amazonaws.com/dev/{proxy+}
ANY - https://xxxxxxx.execute-api.us-east-1.amazonaws.com/
functions:
api: aws-node-express-api-dev-api
layers:
None
```

_Note_: In current form, after deployment, your API is public and can be invoked by anyone. For production deployments, you might want to configure an authorizer. For details on how to do that, refer to [http event docs](https://www.serverless.com/framework/docs/providers/aws/events/apigateway/).
_Note_: In current form, after deployment, your API is public and can be invoked by anyone. For production deployments, you might want to configure an authorizer. For details on how to do that, refer to [`httpApi` event docs](https://www.serverless.com/framework/docs/providers/aws/events/http-api/).

### Invocation

After successful deployment, you can call the created application via HTTP:

```bash
curl https://xxxxxxx.execute-api.us-east-1.amazonaws.com/dev/
curl https://xxxxxxx.execute-api.us-east-1.amazonaws.com/
```

Which should result in the following response:
Expand All @@ -96,7 +87,7 @@ Which should result in the following response:
Calling the `/hello` path with:

```bash
curl https://xxxxxxx.execute-api.us-east-1.amazonaws.com/dev/hello
curl https://xxxxxxx.execute-api.us-east-1.amazonaws.com/hello
```

Should result in the following response:
Expand All @@ -108,7 +99,7 @@ Should result in the following response:
If you try to invoke a path or method that does not have a configured handler, e.g. with:

```bash
curl https://xxxxxxx.execute-api.us-east-1.amazonaws.com/dev/nonexistent
curl https://xxxxxxx.execute-api.us-east-1.amazonaws.com/nonexistent
```

You should receive the following response:
Expand Down
2 changes: 1 addition & 1 deletion aws-node-express-api/serverless.template.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: aws-node-express-api
org: serverlessinc
description: Deploys a Node Express API service with traditional Serverless Framework
description: Deploys a Node Express API service with Serverless Framework
keywords: aws, serverless, faas, lambda, node, express
repo: https://github.com/serverless/examples/aws-node-express-api
license: MIT
9 changes: 1 addition & 8 deletions aws-node-express-api/serverless.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
service: aws-node-express-api

frameworkVersion: '2'


provider:
name: aws
runtime: nodejs12.x
Expand All @@ -12,9 +10,4 @@ functions:
api:
handler: handler.handler
events:
- http:
path: /
method: ANY
- http:
path: /{proxy+}
method: ANY
- httpApi: '*'
25 changes: 8 additions & 17 deletions aws-node-express-dynamodb-api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,19 @@ This template demonstrates how to develop and deploy a simple Node Express API s

## Anatomy of the template

This template configures a single function, `api`, in `serverless.yml` which is responsible for handling all incoming requests thanks to configured `http` events. To learn more about `http` event configuration options, please refer to [http event docs](https://www.serverless.com/framework/docs/providers/aws/events/apigateway/). As the events are configured in a way to accept all incoming requests, `express` framework is responsible for routing and handling requests internally. Implementation takes advantage of `serverless-http` package, which allows you to wrap existing `express` applications. To learn more about `serverless-http`, please refer to corresponding [GitHub repository](https://github.com/dougmoscrop/serverless-http). Additionally, it also handles provisioning of a DynamoDB database that is used for storing data about users. The `express` application exposes two endpoints, `POST /users` and `GET /user/{userId}`, which allow to create and retrieve users.
This template configures a single function, `api`, which is responsible for handling all incoming requests thanks to the `httpApi` event. To learn more about `httpApi` event configuration options, please refer to [httpApi event docs](https://www.serverless.com/framework/docs/providers/aws/events/http-api/). As the event is configured in a way to accept all incoming requests, `express` framework is responsible for routing and handling requests internally. Implementation takes advantage of `serverless-http` package, which allows you to wrap existing `express` applications. To learn more about `serverless-http`, please refer to corresponding [GitHub repository](https://github.com/dougmoscrop/serverless-http). Additionally, it also handles provisioning of a DynamoDB database that is used for storing data about users. The `express` application exposes two endpoints, `POST /users` and `GET /user/{userId}`, which allow to create and retrieve users.

## Usage

### Deployment

This example is made to work with the Serverless Framework dashboard, which includes advanced features such as CI/CD, monitoring, metrics, etc.

In order to deploy with dashboard, you need to first login with:

```
serverless login
```

install dependencies with:
Install dependencies with:

```
npm install
```

and then perform deployment with:
and then deploy with:

```
serverless deploy
Expand Down Expand Up @@ -70,22 +62,21 @@ resources: 13
api keys:
None
endpoints:
ANY - https://xxxxxxx.execute-api.us-east-1.amazonaws.com/dev/
ANY - https://xxxxxxx.execute-api.us-east-1.amazonaws.com/dev/{proxy+}
ANY - https://xxxxxxx.execute-api.us-east-1.amazonaws.com/
functions:
api: aws-node-express-dynamodb-api-dev-api
layers:
None
```

_Note_: In current form, after deployment, your API is public and can be invoked by anyone. For production deployments, you might want to configure an authorizer. For details on how to do that, refer to [http event docs](https://www.serverless.com/framework/docs/providers/aws/events/apigateway/). Additionally, in current configuration, DynamoDB Table will be removed when running `serverless remove`. To retain DynamoDB Table even after removal of the stack, add `DeletionPolicy: Retain` to its resource definition.
_Note_: In current form, after deployment, your API is public and can be invoked by anyone. For production deployments, you might want to configure an authorizer. For details on how to do that, refer to [`httpApi` event docs](https://www.serverless.com/framework/docs/providers/aws/events/http-api/). Additionally, in current configuration, the DynamoDB table will be removed when running `serverless remove`. To retain the DynamoDB table even after removal of the stack, add `DeletionPolicy: Retain` to its resource definition.

### Invocation

After successful deployment, you can create a new user by calling the corresponding endpoint:

```bash
curl --request POST 'https://xxxxxx.execute-api.us-east-1.amazonaws.com/dev/users' --header 'Content-Type: application/json' --data-raw '{"name": "John", "userId": "someUserId"}'
curl --request POST 'https://xxxxxx.execute-api.us-east-1.amazonaws.com/users' --header 'Content-Type: application/json' --data-raw '{"name": "John", "userId": "someUserId"}'
```

Which should result in the following response:
Expand All @@ -97,7 +88,7 @@ Which should result in the following response:
You can later retrieve the user by `userId` by calling the following endpoint:

```bash
curl https://xxxxxxx.execute-api.us-east-1.amazonaws.com/dev/users/someUserId
curl https://xxxxxxx.execute-api.us-east-1.amazonaws.com/users/someUserId
```

Which should result in the following response:
Expand All @@ -114,7 +105,7 @@ If you try to retrieve user that does not exist, you should receive the followin

### Local development

It is also possible to emulate DynamodB, API Gateway and Lambda locally by using `serverless-dynamodb-local` and `serverless-offline` plugins. In order to do that, execute the following commands:
It is also possible to emulate DynamoDB, API Gateway and Lambda locally using the `serverless-dynamodb-local` and `serverless-offline` plugins. In order to do that, run:

```bash
serverless plugin install -n serverless-dynamodb-local
Expand Down
2 changes: 1 addition & 1 deletion aws-node-express-dynamodb-api/serverless.template.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: aws-node-express-dynamodb-api
org: serverlessinc
description: Deploys a Node Express API service backed by DynamoDB with traditional Serverless Framework
description: Deploys a Node Express API service backed by DynamoDB with Serverless Framework
keywords: aws, serverless, faas, lambda, node, express, dynamodb
repo: https://github.com/serverless/examples/aws-node-express-dynamodb-api
license: MIT
15 changes: 3 additions & 12 deletions aws-node-express-dynamodb-api/serverless.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
service: aws-node-express-dynamodb-api

frameworkVersion: '2'

custom:
tableName: 'users-table-${self:provider.stage}'
tableName: 'users-table-${sls:stage}'

provider:
name: aws
runtime: nodejs12.x
lambdaHashingVersion: '20201221'
stage: dev
iam:
role:
statements:
Expand All @@ -30,12 +28,7 @@ functions:
api:
handler: handler.handler
events:
- http:
path: /
method: ANY
- http:
path: /{proxy+}
method: ANY
- httpApi: '*'

resources:
Resources:
Expand All @@ -48,7 +41,5 @@ resources:
KeySchema:
- AttributeName: userId
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
BillingMode: PAY_PER_REQUEST
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good call 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 some templates had this, some others didn't. I figured we might as well make it consistent over this option, it's best to get started.

TableName: ${self:custom.tableName}
2 changes: 2 additions & 0 deletions aws-node-http-api-dynamodb-local/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.serverless
node_modules
Loading