+
-## Concepts
+
-Before we begin, let's run through some of the main concepts behind serverless.
+
-* [Functions](#functions)
-* [Events](#events)
-* [Resources](#resources)
-* [Services](#services)
-* [Plugins](#plugins)
-
-### Functions
-
-Functions are the essential part for any serverless infrastructure. Several functions together form a service. A service typically solves one particular problem in your infrastructure.
-
-### Events
-
-Serverless is used to build event driven architecture. Basically everything which can trigger a function is an event.
-
-Events could be HTTP requests, events fired from a cloud storage (like a S3 bucket), scheduled events, etc.
-
-- [AWS Events](./02-providers/aws/events/)
-
-### Resources
-
-Resources are the different pieces that comprise your infrastructure like databases, storage buckets, API Gateways or other resources your provider lets you configure.
-
-### Services
-
-A *Serverless service* is a group of one or multiple functions and any resources they require. By grouping related functions together, it's easier to share code and resources between those functions. Services are also designed to be completely independent, which helps teams develop more quickly without waiting for others.
-
-### Plugins
-
-Here you can read how to develop your own Serverless plugins. We'll get into details on how to write custom plugins to extend the functionality of Serverless. Furthermore we'll look into the way how you can use your plugin knowledge to integrate your own provider into the Serverless framework.
-
-- [Building plugins](./04-extending-serverless/)
-
-Connect with the community on [gitter](https://gitter.im/serverless/serverless) or in the [Forum](http://forum.serverless.com)
-
-## Contributing
-We love our contributors! Please read our [Contributing Document](../CONTRIBUTING.md) to learn how you can start working on the Framework yourself.
-
-Check out our [help-wanted](https://github.com/serverless/serverless/labels/help-wanted) or [help-wanted-easy](https://github.com/serverless/serverless/labels/help-wanted-easy) labels to find issues we want to move forward on with your help.
-
-## Framework statistics
-
-[Framework statistics](./framework-statistics.md)
+
+
diff --git a/docs/framework-statistics.md b/docs/framework-statistics.md
deleted file mode 100644
index 2ecd652f8..000000000
--- a/docs/framework-statistics.md
+++ /dev/null
@@ -1,30 +0,0 @@
-
-
-# Framework statistics
-
-Serverless will automatically collect anonymous framework statistics. This is done so that we better understand the usage and needs
-of our users to improve Serverless in future releases. However you can always [disable it](#how-to-disable-it).
-
-## What we collect
-
-Our main goal is anonymity. All the data is anonymized and won't reveal who you are or what the project you're working on is / looks like.
-
-Please take a look at the [`logStat()` method](https://github.com/serverless/serverless/blob/master/lib/classes/Utils.js) in the `Utils` class to see what (and how) we collect statistics.
-
-## How it's implemented
-
-We encourage you to look into the source to see more details about the actual implementation.
-
-The whole implementation consists of two parts:
-
-1. The [slstats plugin](https://github.com/serverless/serverless/tree/master/lib/plugins/slstats)
-2. The `logStat()` method you can find in the [Utils class](https://github.com/serverless/serverless/blob/master/lib/classes/Utils.js)
-
-## How to disable it
-
-You can disable it by running the following command: `serverless slstats --disable`.
-You can always run `serverless slstats --enable` to enable it again.
diff --git a/docs/providers/README.md b/docs/providers/README.md
new file mode 100644
index 000000000..3d7509d0b
--- /dev/null
+++ b/docs/providers/README.md
@@ -0,0 +1,19 @@
+
+
+
+### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/)
+
+
+# Serverless Infrastructure Providers
+
+Providers are where your serverless functions run in the cloud.
+
+Under the hood, the serverless framework is deploying your code to a cloud provider like Amazon web services or Google Cloud functions.
+
+You specify your provider in your services `serverless.yml` file.
+
+* [Back to main documentation](../README.md)
diff --git a/docs/providers/aws/README.md b/docs/providers/aws/README.md
new file mode 100644
index 000000000..6a40cd2c9
--- /dev/null
+++ b/docs/providers/aws/README.md
@@ -0,0 +1,17 @@
+
+
+
+### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/aws/)
+
+
+# Serverless AWS Provider Documentation
+
+Welcome to the Serverless Amazon Web Services documentation! Please select a section on the left to get started.
+
+**Note:** Before continuing [AWS system credentials](./guide/credentials/) are required for using the CLI.
+
+If you have questions, join the [chat in gitter](https://gitter.im/serverless/serverless) or [post over on the forums](https://gitter.im/serverless/serverless)
diff --git a/docs/providers/aws/cli-reference/README.md b/docs/providers/aws/cli-reference/README.md
new file mode 100644
index 000000000..e601555a4
--- /dev/null
+++ b/docs/providers/aws/cli-reference/README.md
@@ -0,0 +1,17 @@
+
+
+
+### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/aws/cli-reference/)
+
+
+# Serverless AWS Lambda CLI Reference
+
+Welcome to the Serverless AWS Lambda CLI Reference! Please select a section on the left to get started.
+
+**Note:** Before continuing [AWS system credentials](https://serverless.com/framework/docs/providers/aws/guide/credentials/) are required for using the CLI.
+
+If you have questions, join the [chat in gitter](https://gitter.im/serverless/serverless) or [post over on the forums](https://gitter.im/serverless/serverless)
diff --git a/docs/03-cli-reference/01-create.md b/docs/providers/aws/cli-reference/create.md
similarity index 80%
rename from docs/03-cli-reference/01-create.md
rename to docs/providers/aws/cli-reference/create.md
index 855fe543b..a3a0629bf 100644
--- a/docs/03-cli-reference/01-create.md
+++ b/docs/providers/aws/cli-reference/create.md
@@ -1,15 +1,20 @@
+
+### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/aws/cli-reference/create)
+
+
# Create
Creates a new service in the current working directory based on the provided template.
-```
+```bash
serverless create --template aws-nodejs
```
@@ -37,7 +42,7 @@ Most commonly used templates:
### Creating a new service
-```
+```bash
serverless create --template aws-nodejs --name my-special-service
```
@@ -49,7 +54,7 @@ The provider which is used for deployment later on is AWS (Amazon web services).
### Creating a named service in a (new) directory
-```
+```bash
serverless create --template aws-nodejs --path my-new-service
```
@@ -58,4 +63,4 @@ will be generated in the `my-new-service` directory. This directory will be crea
will use the already present directory.
Additionally Serverless will rename the service according to the path you provide. In this example the service will be
-renamed to `my-new-service`.
+renamed to `my-new-service`.
\ No newline at end of file
diff --git a/docs/03-cli-reference/03-deploy.md b/docs/providers/aws/cli-reference/deploy.md
similarity index 80%
rename from docs/03-cli-reference/03-deploy.md
rename to docs/providers/aws/cli-reference/deploy.md
index 75f2e560c..7c085b279 100644
--- a/docs/03-cli-reference/03-deploy.md
+++ b/docs/providers/aws/cli-reference/deploy.md
@@ -1,16 +1,21 @@
+
+### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/aws/cli-reference/deploy)
+
+
# Deploy
Deploys your service. You can access all created deployment artifacts in the `.serverless` folder.
-```
-serverless deploy [function|list]
+```bash
+serverless deploy [function]
```
## Options
@@ -25,7 +30,7 @@ serverless deploy [function|list]
### Deployment without stage and region options
-```
+```bash
serverless deploy
```
@@ -34,22 +39,13 @@ provider in the default stage (`dev`) to the default region (`us-east-1`).
### Deployment with stage and region options
-```
+```bash
serverless deploy --stage production --region eu-central-1
```
With this example we've defined that we want our service to be deployed to the `production` stage in the region
`eu-central-1`.
-## List existing deploys
-
-```
-serverless deploy list
-```
-
-Running this command will list your recent deployments available in your S3 deployment bucket. It will use
-stage and region from the provider config.
-
## Provided lifecycle events
- `deploy:cleanup`
- `deploy:initialize`
@@ -58,5 +54,4 @@ stage and region from the provider config.
- `deploy:compileFunctions`
- `deploy:compileEvents`
- `deploy:deploy`
-- `deploy:function:deploy`
-- `deploy:list:log`
+- `deploy:function:deploy`
\ No newline at end of file
diff --git a/docs/03-cli-reference/06-info.md b/docs/providers/aws/cli-reference/info.md
similarity index 83%
rename from docs/03-cli-reference/06-info.md
rename to docs/providers/aws/cli-reference/info.md
index 324eb1c25..f066a2ac8 100644
--- a/docs/03-cli-reference/06-info.md
+++ b/docs/providers/aws/cli-reference/info.md
@@ -1,10 +1,15 @@
+
+### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/aws/cli-reference/info)
+
+
# Info
Displays information about the deployed service.
@@ -30,7 +35,7 @@ See the example below for an example output.
**Example:**
-```
+```bash
$ serverless info
Service Information
@@ -46,8 +51,10 @@ functions:
```
#### Verbose
+
When using the `--verbose` flag, the `info` command will also append all Stack Outputs to the output:
-```
+
+```bash
$ serverless info --verbose
Service Information
@@ -69,4 +76,4 @@ CreateThumbnailsLambdaFunctionArn: arn:aws:lambda:us-east-1:377024778620:functio
TakeScreenshotLambdaFunctionArn: arn:aws:lambda:us-east-1:377024778620:function:lambda-screenshots-dev-takeScreenshot
ServiceEndpoint: https://12341jc801.execute-api.us-east-1.amazonaws.com/dev
ServerlessDeploymentBucketName: lambda-screenshots-dev-serverlessdeploymentbucket-15b7pkc04f98a
-```
+```
\ No newline at end of file
diff --git a/docs/providers/aws/cli-reference/install.md b/docs/providers/aws/cli-reference/install.md
new file mode 100644
index 000000000..aa2046c7b
--- /dev/null
+++ b/docs/providers/aws/cli-reference/install.md
@@ -0,0 +1,35 @@
+
+
+
+### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/aws/cli-reference/install)
+
+
+# Install
+
+Installs a service from a GitHub URL in the current working directory.
+
+```bash
+serverless install --url https://github.com/some/service
+```
+
+## Options
+- `--url` or `-u` The services GitHub URL. **Required**.
+
+## Provided lifecycle events
+- `install:install`
+
+## Examples
+
+### Installing a service from a GitHub URL
+
+```bash
+serverless install --url https://github.com/johndoe/authentication
+```
+
+This example will download the .zip file of the `authentication` service from GitHub, create a new directory with the name `authentication` in the current working directory and unzips the files in this directory.
\ No newline at end of file
diff --git a/docs/03-cli-reference/04-invoke.md b/docs/providers/aws/cli-reference/invoke.md
similarity index 75%
rename from docs/03-cli-reference/04-invoke.md
rename to docs/providers/aws/cli-reference/invoke.md
index 645ae7dc7..82e67b129 100644
--- a/docs/03-cli-reference/04-invoke.md
+++ b/docs/providers/aws/cli-reference/invoke.md
@@ -1,10 +1,15 @@
+
+### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/aws/cli-reference/invoke)
+
+
# Invoke
Invokes a previously deployed function. It allows to send event data to the function and read logs and display other important information of the function invoke.
@@ -17,11 +22,11 @@ serverless invoke --function functionName
- `--function` or `-f` The name of the function in your service that you want to invoke. **Required**.
- `--stage` or `-s` The stage in your service you want to invoke your function in.
- `--region` or `-r` The region in your stage that you want to invoke your function in.
-- `--path` or `-p` The path to a json file holding input data to be passed to the invoked function. Either an absolute or
- relative (to the root directory of your service) may be given.
+- `--path` or `-p` The path to a json file holding input data to be passed to the invoked function. This path is relative to the
+root directory of the service.
- `--type` or `-t` The type of invocation. Either `RequestResponse`, `Event` or `DryRun`. Default is `RequestResponse`.
- `--log` or `-l` If set to `true` and invocation type is `RequestResponse`, it will output logging data of the invocation.
- Default is `false`.
+Default is `false`.
## Provided lifecycle events
- `invoke:invoke`
@@ -30,7 +35,7 @@ serverless invoke --function functionName
### AWS
-```
+```bash
serverless invoke --function functionName --stage dev --region us-east-1
```
@@ -39,7 +44,7 @@ output the result of the invocation in your terminal.
#### Function invocation with logging
-```
+```bash
serverless invoke --function functionName --stage dev --region us-east-1 --log
```
@@ -47,15 +52,9 @@ Just like the first example, but will also outputs logging information about you
#### Function invocation with data passing
-```
+```bash
serverless invoke --function functionName --stage dev --region us-east-1 --path lib/data.json
```
This example will pass the json data in the `lib/data.json` file (relative to the root of the service) while invoking
-the specified/deployed function.
-
-```
-serverless invoke --function functionName --stage dev --region us-east-1 --path /tmp/data.json
-```
-
-This example will pass the json data in the `/tmp/data.json` file while invoking the specified/deployed function.
+the specified/deployed function.
\ No newline at end of file
diff --git a/docs/03-cli-reference/05-logs.md b/docs/providers/aws/cli-reference/logs.md
similarity index 85%
rename from docs/03-cli-reference/05-logs.md
rename to docs/providers/aws/cli-reference/logs.md
index 85d9f1200..7782aa54b 100644
--- a/docs/03-cli-reference/05-logs.md
+++ b/docs/providers/aws/cli-reference/logs.md
@@ -1,10 +1,15 @@
+
+### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/aws/cli-reference/logs)
+
+
# Logs
Lets you watch the logs of a specific function.
@@ -18,9 +23,9 @@ serverless logs -f hello
- `--function` or `-f` The function you want to fetch the logs for. **Required**
- `--stage` or `-s` The stage you want to view the function logs for. If not provided, the plugin will use the default stage listed in `serverless.yml`. If that doesn't exist either it'll just fetch the logs from the `dev` stage.
- `--region` or `-r` The region you want to view the function logs for. If not provided, the plugin will use the default region listed in `serverless.yml`. If that doesn't exist either it'll just fetch the logs from the `us-east-1` region.
-- `--startTime` A specific unit in time to start fetching logs from (ie: `2010-10-20` or `1469705761`). All absolute dates/datetimes .e.g `2010-10-20` are parsed as UTC. Here's a list of the supported string formats:
+- `--startTime` A specific unit in time to start fetching logs from (ie: `2010-10-20` or `1469705761`). Here's a list of the supported string formats:
-```
+```bash
30m # since 30 minutes ago
2h # since 2 hours ago
3d # since 3 days ago
@@ -71,4 +76,4 @@ Serverless will tail the CloudWatch log output and print new log messages coming
```bash
serverless logs -f hello --filter serverless
```
-This will fetch only the logs that contain the string `serverless`
+This will fetch only the logs that contain the string `serverless`
\ No newline at end of file
diff --git a/docs/03-cli-reference/07-remove.md b/docs/providers/aws/cli-reference/remove.md
similarity index 61%
rename from docs/03-cli-reference/07-remove.md
rename to docs/providers/aws/cli-reference/remove.md
index 63fbc2d34..dd097cf70 100644
--- a/docs/03-cli-reference/07-remove.md
+++ b/docs/providers/aws/cli-reference/remove.md
@@ -1,15 +1,20 @@
+
+### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/aws/cli-reference/remove)
+
+
# Remove
Removes the deployed service which is defined in your current working directory.
-```
+```bash
serverless remove
```
@@ -25,8 +30,8 @@ serverless remove
### Removal of service in specific stage and region
-```
+```bash
serverless remove --stage dev --region us-east-1
```
-This example will remove the deployed service of your current working directory with the stage `dev` and the region `us-east-1`.
+This example will remove the deployed service of your current working directory with the stage `dev` and the region `us-east-1`.
\ No newline at end of file
diff --git a/docs/providers/aws/cli-reference/slstats.md b/docs/providers/aws/cli-reference/slstats.md
new file mode 100644
index 000000000..0665f014d
--- /dev/null
+++ b/docs/providers/aws/cli-reference/slstats.md
@@ -0,0 +1,36 @@
+
+
+
+### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/aws/cli-reference/slstats)
+
+
+# Serverless Statistics
+
+This plugin implements a way to toggle framework statistics.
+
+```bash
+serverless slstats --enable
+```
+
+## Options
+- `--enable` or `-e`.
+- `--disable` or `-d`
+
+## Provided lifecycle events
+- `slstats:slstats`
+
+## Examples
+
+### Disabling it
+
+```bash
+serverless slstats --disable
+```
+
+This example will disable framework statistics.
diff --git a/docs/providers/aws/events/README.md b/docs/providers/aws/events/README.md
new file mode 100644
index 000000000..87d4d6601
--- /dev/null
+++ b/docs/providers/aws/events/README.md
@@ -0,0 +1,17 @@
+
+
+
+### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/aws/events/)
+
+
+# Serverless AWS Lambda Events
+
+Welcome to the Serverless AWS Lambda Events Glossary! Please select a section on the left to get started.
+
+**Note:** Before continuing [AWS system credentials](https://serverless.com/framework/docs/providers/aws/guide/credentials/) are required for using the CLI.
+
+If you have questions, join the [chat in gitter](https://gitter.im/serverless/serverless) or [post over on the forums](https://gitter.im/serverless/serverless)
diff --git a/docs/02-providers/aws/events/01-apigateway.md b/docs/providers/aws/events/apigateway.md
similarity index 80%
rename from docs/02-providers/aws/events/01-apigateway.md
rename to docs/providers/aws/events/apigateway.md
index 501cb4329..bc68b833c 100644
--- a/docs/02-providers/aws/events/01-apigateway.md
+++ b/docs/providers/aws/events/apigateway.md
@@ -1,16 +1,36 @@
+
+### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/aws/events/apigateway)
+
+
# API Gateway
-## Simple http setup
+To create HTTP endpoints as Event sources for your AWS Lambda Functions, use the Serverless Framework's easy AWS API Gateway Events syntax.
+
+There are two ways you can configure your HTTP endpoints to integrate with your AWS Lambda Functions:
+* lambda-proxy (Recommended)
+* lambda
+
+The difference between these is `lambda-proxy` automatically passes the content of the HTTP request into your AWS Lambda function (headers, body, etc.) and allows you to configure your response (headers, status code, body) in the code of your AWS Lambda Function. Whereas, the `lambda` method makes you explicitly define headers, status codes, and more in the configuration of each API Gateway Endpoint (not in code). We highly recommend using the `lambda-proxy` method if it supports your use-case, since the `lambda` method is highly tedious.
+
+By default, the Framework uses the `lambda-proxy` method (i.e., everything is passed into your Lambda), and nothing is required by you to enable it.
+
+## Lambda Proxy Integration
+
+### Simple HTTP Endpoint
This setup specifies that the `index` function should be run when someone accesses the API gateway at `users/index` via
a `GET` request.
+Here's an example:
+
```yml
# serverless.yml
functions:
@@ -20,7 +40,33 @@ functions:
- http: GET users/index
```
-## Http setup with extended event options
+```javascript
+// users.js
+
+'use strict';
+
+exports.handler = function(event, context, callback) {
+
+ console.log(event); // Contains incoming request data (e.g., query params, headers and more)
+
+ const response = {
+ statusCode: 200,
+ headers: {
+ "x-custom-header" : "My Header Value"
+ },
+ body: JSON.stringify({ "message": "Hello World!" })
+ };
+
+ callback(null, response);
+};
+```
+
+**Note:** When the body is a JSON-Document, you must parse it yourself:
+```
+JSON.parse(event.body);
+```
+
+### HTTP Endpoint with Extended Options
Here we've defined an POST endpoint for the path `posts/create`.
@@ -35,9 +81,155 @@ functions:
method: post
```
-## Request parameters
+### Enabling CORS
+To set CORS configurations for your HTTP endpoints, simply modify your event configurations as follows:
-You can pass optional and required parameters to your functions, so you can use them in for example Api Gateway tests and SDK generation. Marking them as `true` will make them required, `false` will make them optional.
+```yml
+functions:
+ hello:
+ handler: handler.hello
+ events:
+ - http:
+ path: user/create
+ method: get
+ cors: true
+```
+
+If you want to use CORS with the lambda-proxy integration, remember to include `Access-Control-Allow-Origin` in your returned headers object, like this:
+
+```javascript
+// users.js
+
+'use strict';
+
+exports.handler = function(event, context, callback) {
+
+ const response = {
+ statusCode: 200,
+ headers: {
+ "Access-Control-Allow-Origin" : "*" // Required for CORS support to work
+ },
+ body: JSON.stringify({ "message": "Hello World!" })
+ };
+
+ callback(null, response);
+};
+```
+
+### HTTP Endpoints with Custom Authorizers
+
+Custom Authorizers allow you to run an AWS Lambda Function before your targeted AWS Lambda Function. This is useful for Microservice Architectures or when you simply want to do some Authorization before running your business logic.
+
+You can enable Custom Authorizers for your HTTP endpoint by setting the Authorizer in your `http` event to another function
+in the same service, as shown in the following example:
+
+```yml
+# serverless.yml
+functions:
+ create:
+ handler: posts.create
+ events:
+ - http:
+ path: posts/create
+ method: post
+ authorizer: authorizerFunc
+ authorizerFunc:
+ handler: handlers.authorizerFunc
+```
+Or, if you want to configure the Authorizer with more options, you can turn the `authorizer` property into an object as
+shown in the following example:
+
+```yml
+# serverless.yml
+functions:
+ create:
+ handler: posts.create
+ events:
+ - http:
+ path: posts/create
+ method: post
+ authorizer:
+ name: authorizerFunc
+ resultTtlInSeconds: 0
+ identitySource: method.request.header.Authorization
+ identityValidationExpression: someRegex
+ authorizerFunc:
+ handler: handlers.authorizerFunc
+```
+
+If the Authorizer function does not exist in your service but exists in AWS, you can provide the ARN of the Lambda
+function instead of the function name, as shown in the following example:
+
+```yml
+# serverless.yml
+functions:
+ create:
+ handler: posts.create
+ events:
+ - http:
+ path: posts/create
+ method: post
+ authorizer: xxx:xxx:Lambda-Name
+```
+
+Or, if you want to configure the Authorizer with more options, you can turn the `authorizer` property into an object as
+shown in the following example:
+
+```yml
+# serverless.yml
+functions:
+ create:
+ handler: posts.create
+ events:
+ - http:
+ path: posts/create
+ method: post
+ authorizer:
+ arn: xxx:xxx:Lambda-Name
+ resultTtlInSeconds: 0
+ identitySource: method.request.header.Authorization
+ identityValidationExpression: someRegex
+```
+
+### Catching Exceptions In Your Lambda Function
+
+In case an exception is thrown in your lambda function AWS will send an error message with `Process exited before completing request`. This will be caught by the regular expression for the 500 HTTP status and the 500 status will be returned.
+
+### Setting API keys for your Rest API
+You can specify a list of API keys to be used by your service Rest API by adding an `apiKeys` array property to the
+`provider` object in `serverless.yml`. You'll also need to explicitly specify which endpoints are `private` and require
+one of the api keys to be included in the request by adding a `private` boolean property to the `http` event object you
+want to set as private.
+
+Here's an example configuration for setting API keys for your service Rest API:
+
+```yml
+service: my-service
+provider:
+ name: aws
+ apiKeys:
+ - myFirstKey
+ - ${env:MY_API_KEY} # you can hide it in a serverless variable
+functions:
+ hello:
+ events:
+ - http:
+ path: user/create
+ method: get
+ private: true
+```
+
+Please note that those are the API keys names, not the actual values. Once you deploy your service, the value of those API keys will be auto generated by AWS and printed on the screen for you to use.
+
+Clients connecting to this Rest API will then need to set any of these API keys values in the `x-api-key` header of their request. This is only necessary for functions where the `private` property is set to true.
+
+## Lambda Integration
+
+This method is more complicated and involves a lot more configuration of the `http` event syntax.
+
+### Request Parameters
+
+To pass optional and required parameters to your functions, so you can use them in API Gateway tests and SDK generation, marking them as `true` will make them required, `false` will make them optional.
```yml
# serverless.yml
@@ -60,7 +252,7 @@ functions:
bar: false
```
-In order for path variables to work, ApiGateway also needs them in the method path itself, like so:
+In order for path variables to work, API Gateway also needs them in the method path itself, like so:
```yml
# serverless.yml
@@ -78,78 +270,9 @@ functions:
id: true
```
-## Integration types
+### Request templates
-Serverless supports the following integration types:
-
-- `lambda`
-- `lambda-proxy`
-
-Here's a simple example which demonstrates how you can set the `integration` type for your `http` event:
-
-```yml
-# serverless.yml
-functions:
- get:
- handler: users.get
- events:
- - http:
- path: users
- method: get
- integration: lambda
-```
-
-### `lambda-proxy`
-
-**Important:** Serverless defaults to this integration type if you don't setup another one.
-Furthermore any `request` or `response` configuration will be ignored if this `integration` type is used.
-
-`lambda-proxy` simply passes the whole request as is (regardless of the content type, the headers, etc.) directly to the
-Lambda function. This means that you don't have to setup custom request / response configuration (such as templates, the
-passthrough behavior, etc.).
-
-Your function needs to return corresponding response information.
-
-Here's an example for a JavaScript / Node.js function which shows how this might look like:
-
-```javascript
-'use strict';
-
-exports.handler = function(event, context, callback) {
- const responseBody = {
- message: "Hello World!",
- input: event
- };
-
- const response = {
- statusCode: 200,
- headers: {
- "x-custom-header" : "My Header Value"
- },
- body: JSON.stringify(responseBody)
- };
-
- callback(null, response);
-};
-```
-
-**Note:** If you want to use CORS with the lambda-proxy integration, remember to include `Access-Control-Allow-Origin` in your returned headers object.
-
-Take a look at the [AWS documentation](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-create-api-as-simple-proxy-for-lambda.html)
-for more information about this.
-
-### `lambda`
-
-The `lambda` integration type should be used if you want more control over the `request` and `response` configurations.
-
-Serverless ships with defaults for the request / response configuration (such as request templates, error code mappings,
-default passthrough behaviour) but you can always configure those accordingly when you set the `integration` type to `lambda`.
-
-## Request templates
-
-**Note:** The request configuration can only be used when the integration type is set to `lambda`.
-
-### Default request templates
+#### Default Request Templates
Serverless ships with the following default request templates you can use out of the box:
@@ -168,7 +291,7 @@ Both templates give you access to the following properties you can access with t
- identity
- stageVariables
-### Using custom request templates
+#### Custom Request Templates
However you can define and use your own request templates as follows (you can even overwrite the default request templates
by defining a new request template for an existing content type):
@@ -210,8 +333,7 @@ functions:
You can then access the query string `https://example.com/dev/whatever?bar=123` by `event.foo` in the lambda function.
If you want to spread a string into multiple lines, you can use the `>` or `|` syntax, but the following strings have to be all indented with the same amount, [read more about `>` syntax](http://stackoverflow.com/questions/3790454/in-yaml-how-do-i-break-a-string-over-multiple-lines).
-
-### Pass Through Behavior
+#### Pass Through Behavior
API Gateway provides multiple ways to handle requests where the Content-Type header does not match any of the specified mapping templates. When this happens, the request payload will either be passed through the integration request *without transformation* or rejected with a `415 - Unsupported Media Type`, depending on the configuration.
You can define this behavior as follows (if not specified, a value of **NEVER** will be used):
@@ -243,13 +365,11 @@ See the [api gateway documentation](https://docs.aws.amazon.com/apigateway/lates
- A missing/empty request Content-Type is considered to be the API Gateway default (`application/json`)
- API Gateway docs refer to "WHEN_NO_TEMPLATE" (singular), but this will fail during creation as the actual value should be "WHEN_NO_TEMPLATES" (plural)
-## Responses
-
-**Note:** The response configuration can only be used when the integration type is set to `lambda`.
+### Responses
Serverless lets you setup custom headers and a response template for your `http` event.
-### Using custom response headers
+#### Custom Response Headers
Here's an example which shows you how you can setup a custom response header:
@@ -271,7 +391,7 @@ functions:
for your header values. Headers are passed to API Gateway exactly like you define them. Passing the `Cache-Control` header
as `"'max-age=120'"` means API Gateway will receive the value as `'max-age=120'` (enclosed with single quotes).
-### Using a custom response template
+### Custom Response Templates
Sometimes you'll want to define a custom response template API Gateway should use to transform your lambdas output.
Here's an example which will transform the return value of your lambda so that the browser renders it as HTML:
@@ -298,7 +418,7 @@ the `${file(templatefile)}` syntax.
Serverless ships with default status codes you can use to e.g. signal that a resource could not be found (404) or that
the user is not authorized to perform the action (401). Those status codes are regex definitions that will be added to your API Gateway configuration.
-#### Overview of available status codes
+#### Available Status Codes
| Status Code | Meaning |
| --- | --- |
@@ -311,7 +431,7 @@ the user is not authorized to perform the action (401). Those status codes are r
| 502 | Bad Gateway |
| 504 | Gateway Timeout |
-#### Using status codes
+#### Using Status Codes
To return a given status code you simply need to add square brackets with the status code of your choice to your
returned message like this: `[401] You are not authorized to access this resource!`.
@@ -324,7 +444,7 @@ module.exports.hello = (event, context, cb) => {
}
```
-#### Custom status codes
+#### Custom Status Codes
You can override the defaults status codes supplied by Serverless. You can use this to change the default status code, add/remove status codes, or change the templates and headers used for each status code. Use the pattern key to change the selection process that dictates what code is returned.
@@ -380,114 +500,7 @@ functions:
Content-Type: "'application/json+hal'"
```
-### Catching exceptions in your Lambda function
-
-In case an exception is thrown in your lambda function AWS will send an error message with `Process exited before completing request`. This will be caught by the regular expression for the 500 HTTP status and the 500 status will be returned.
-
-### Http setup with custom authorizer
-
-You can enable custom authorizers for your HTTP endpoint by setting the authorizer in your http event to another function
-in the same service, as shown in the following example
-
-```yml
-# serverless.yml
-functions:
- create:
- handler: posts.create
- events:
- - http:
- path: posts/create
- method: post
- authorizer: authorizerFunc
- authorizerFunc:
- handler: handlers.authorizerFunc
-```
-Or, if you want to configure the authorizer with more options, you can turn the `authorizer` property into an object as
-shown in the following example:
-
-```yml
-# serverless.yml
-functions:
- create:
- handler: posts.create
- events:
- - http:
- path: posts/create
- method: post
- authorizer:
- name: authorizerFunc
- resultTtlInSeconds: 0
- identitySource: method.request.header.Authorization
- identityValidationExpression: someRegex
- authorizerFunc:
- handler: handlers.authorizerFunc
-```
-
-### Http setup with custom authorizer (via ARN)
-If the authorizer function does not exist in your service but exists in AWS, you can provide the ARN of the Lambda
-function instead of the function name, as shown in the following example:
-
-```yml
-# serverless.yml
-functions:
- create:
- handler: posts.create
- events:
- - http:
- path: posts/create
- method: post
- authorizer: xxx:xxx:Lambda-Name
-```
-
-Or, if you want to configure the authorizer with more options, you can turn the `authorizer` property into an object as
-shown in the following example:
-
-```yml
-# serverless.yml
-functions:
- create:
- handler: posts.create
- events:
- - http:
- path: posts/create
- method: post
- authorizer:
- arn: xxx:xxx:Lambda-Name
- resultTtlInSeconds: 0
- identitySource: method.request.header.Authorization
- identityValidationExpression: someRegex
-```
-
-## Setting API keys for your Rest API
-You can specify a list of API keys to be used by your service Rest API by adding an `apiKeys` array property to the
-`provider` object in `serverless.yml`. You'll also need to explicitly specify which endpoints are `private` and require
-one of the api keys to be included in the request by adding a `private` boolean property to the `http` event object you
-want to set as private.
-
-Here's an example configuration for setting API keys for your service Rest API:
-
-```yml
-service: my-service
-provider:
- name: aws
- apiKeys:
- - myFirstKey
- - ${env:MY_API_KEY} # you can hide it in a serverless variable
-functions:
- hello:
- events:
- - http:
- path: user/create
- method: get
- private: true
-```
-
-Please note that those are the API keys names, not the actual values. Once you deploy your service, the value of those API keys will be auto generated by AWS and printed on the screen for you to use.
-
-Clients connecting to this Rest API will then need to set any of these API keys values in the `x-api-key` header of their request. This is only necessary for functions where the `private` property is set to true.
-
-## Enabling CORS for your endpoints
-To set CORS configurations for your HTTP endpoints, simply modify your event configurations as follows:
+## Enabling CORS with the Lambda Integration Method
```yml
functions:
@@ -537,7 +550,7 @@ module.exports.hello = (event, context, cb) => {
}
```
-## Setting an HTTP proxy on API Gateway
+## Setting an HTTP Proxy on API Gateway
To set up an HTTP proxy, you'll need two CloudFormation templates, one for the endpoint (known as resource in CF), and
one for method. These two templates will work together to construct your proxy. So if you want to set `your-app.com/serverless` as a proxy for `serverless.com`, you'll need the following two templates in your `serverless.yml`:
diff --git a/docs/02-providers/aws/events/02-s3.md b/docs/providers/aws/events/s3.md
similarity index 84%
rename from docs/02-providers/aws/events/02-s3.md
rename to docs/providers/aws/events/s3.md
index 45b54e8f4..7b0eb3770 100644
--- a/docs/02-providers/aws/events/02-s3.md
+++ b/docs/providers/aws/events/s3.md
@@ -1,16 +1,22 @@
+
+### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/aws/events/s3)
+
+
# S3
## Simple event definition
This will create a `photos` bucket which fires the `resize` function when an object is added or modified inside the bucket. A hardcoded bucket name can lead to issues as a bucket name can only be used once in S3. For that you can use the [Serverless Variable syntax](../../../01-guide/08-serverless-variables.md) and add dynamic elements to the bucket name.
-```yml
+```yaml
functions:
resize:
handler: resize.handler
@@ -22,7 +28,7 @@ functions:
This will create a bucket `photos`. The `users` function is called whenever an object is removed from the bucket. Check out the [AWS documentation](http://docs.aws.amazon.com/AmazonS3/latest/dev/NotificationHowTo.html#notification-how-to-event-types-and-destinations) to learn more about all the different event types that can be configured.
-```yml
+```yaml
functions:
users:
handler: users.handler
@@ -36,11 +42,11 @@ functions:
This will create a bucket `photos`. The `users` function is called whenever an image with `.jpg` extension is uploaded to folder `uploads` in the bucket. Check out the [AWS documentation](http://docs.aws.amazon.com/AmazonS3/latest/dev/NotificationHowTo.html#notification-how-to-filtering) to learn more about all the different filter types that can be configured.
-```yml
+```yaml
functions:
users:
handler: users.handler
- rules:
+ events:
- s3:
bucket: photos
event: s3:ObjectCreated:*
diff --git a/docs/02-providers/aws/events/03-schedule.md b/docs/providers/aws/events/schedule.md
similarity index 63%
rename from docs/02-providers/aws/events/03-schedule.md
rename to docs/providers/aws/events/schedule.md
index beff32313..6c7a1704c 100644
--- a/docs/02-providers/aws/events/03-schedule.md
+++ b/docs/providers/aws/events/schedule.md
@@ -1,14 +1,20 @@
+
+### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/aws/events/schedule)
+
+
# Schedule
The following config will attach a schedule event and causes the function `crawl` to be called every 2 hours. The configuration allows you to attach multiple schedules to the same function. You can either use the `rate` or `cron` syntax. Take a look at the [AWS schedule syntax documentation](http://docs.aws.amazon.com/AmazonCloudWatch/latest/events/ScheduledEvents.html) for more details.
-```yml
+```yaml
functions:
crawl:
handler: crawl
@@ -22,7 +28,7 @@ functions:
This will create and attach a schedule event for the `aggregate` function which is disabled. If enabled it will call
the `aggregate` function every 10 minutes.
-```yml
+```yaml
functions:
aggregate:
handler: statistics.handler
@@ -30,4 +36,7 @@ functions:
- schedule:
rate: rate(10 minutes)
enabled: false
+ - schedule:
+ rate: cron(0 12 * * ? *)
+ enabled: false
```
diff --git a/docs/02-providers/aws/events/04-sns.md b/docs/providers/aws/events/sns.md
similarity index 82%
rename from docs/02-providers/aws/events/04-sns.md
rename to docs/providers/aws/events/sns.md
index 49b1c6f72..fa0efbffc 100644
--- a/docs/02-providers/aws/events/04-sns.md
+++ b/docs/providers/aws/events/sns.md
@@ -1,9 +1,15 @@
+
+### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/aws/events/sns)
+
+
# SNS
In the following example we create a new SNS topic with the name `dispatch` which is bound to the `dispatcher` function. The function will be called every time a message is sent to the `dispatch` topic.
diff --git a/docs/02-providers/aws/events/05-streams.md b/docs/providers/aws/events/streams.md
similarity index 72%
rename from docs/02-providers/aws/events/05-streams.md
rename to docs/providers/aws/events/streams.md
index 66dd0af7e..803ec6fa5 100644
--- a/docs/02-providers/aws/events/05-streams.md
+++ b/docs/providers/aws/events/streams.md
@@ -1,9 +1,15 @@
+
+### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/aws/events/streams)
+
+
# DynamoDB / Kinesis Streams
This setup specifies that the `compute` function should be triggered whenever the corresponding DynamoDB table is modified (e.g. a new entry is added).
diff --git a/docs/providers/aws/examples/README.md b/docs/providers/aws/examples/README.md
new file mode 100644
index 000000000..f4cebe05c
--- /dev/null
+++ b/docs/providers/aws/examples/README.md
@@ -0,0 +1,20 @@
+
+
+
+### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/aws/examples/)
+
+
+# Serverless AWS Lambda Examples
+
+Welcome to the Serverless Amazon Web Services Examples! Please select an example below:
+
+* [Hello World](./hello-world)
+* [Using External Libraries](./using-external-libraries)
+* [Cron](./cron)
+* [Serving HTML page](./web-serving-html)
+
+If you have questions, join the [chat in gitter](https://gitter.im/serverless/serverless) or [post over on the forums](https://gitter.im/serverless/serverless)
diff --git a/docs/providers/aws/examples/cron/README.md b/docs/providers/aws/examples/cron/README.md
new file mode 100644
index 000000000..75a70f9f6
--- /dev/null
+++ b/docs/providers/aws/examples/cron/README.md
@@ -0,0 +1,20 @@
+
+
+
+### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/aws/examples/cron/)
+
+
+# Cron Example
+
+Create a scheduled task with AWS Lambda and automate all the things! Examples:
+
+* [JavaScript](./node)
+
+For more information on running cron with Serverless check out the [Tutorial: Serverless Scheduled Tasks](https://parall.ax/blog/view/3202/tutorial-serverless-scheduled-tasks) by parallax.
+
+For more information on `schedule` event check out [our docs](../../events/schedule.md).
diff --git a/docs/providers/aws/examples/cron/node/README.md b/docs/providers/aws/examples/cron/node/README.md
new file mode 100644
index 000000000..87de2000f
--- /dev/null
+++ b/docs/providers/aws/examples/cron/node/README.md
@@ -0,0 +1,20 @@
+
+
+
+### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/aws/examples/cron/node)
+
+
+# JavaScript Cron Example
+
+This is an example of creating a function that runs as a cron job.
+
+To see your job running tail your logs with:
+
+```bash
+serverless logs -function cron -tail
+```
diff --git a/docs/02-providers/aws/examples/cron/node/handler.js b/docs/providers/aws/examples/cron/node/handler.js
similarity index 50%
rename from docs/02-providers/aws/examples/cron/node/handler.js
rename to docs/providers/aws/examples/cron/node/handler.js
index 5fb485788..980b35d28 100644
--- a/docs/02-providers/aws/examples/cron/node/handler.js
+++ b/docs/providers/aws/examples/cron/node/handler.js
@@ -2,5 +2,5 @@
module.exports.run = () => {
const time = new Date();
- console.log(`Your cron ran ${time}`);
+ console.log(`Your cron ran ${time}`); // eslint-disable-line no-console
};
diff --git a/docs/02-providers/aws/examples/cron/node/serverless.yml b/docs/providers/aws/examples/cron/node/serverless.yml
similarity index 78%
rename from docs/02-providers/aws/examples/cron/node/serverless.yml
rename to docs/providers/aws/examples/cron/node/serverless.yml
index c24b21466..85e06c872 100644
--- a/docs/02-providers/aws/examples/cron/node/serverless.yml
+++ b/docs/providers/aws/examples/cron/node/serverless.yml
@@ -8,4 +8,4 @@ functions:
cron:
handler: handler.run
events:
- - schedule: rate(1 minute)
\ No newline at end of file
+ - schedule: rate(1 minute)
diff --git a/docs/providers/aws/examples/hello-world/README.md b/docs/providers/aws/examples/hello-world/README.md
new file mode 100644
index 000000000..7a87e5e4f
--- /dev/null
+++ b/docs/providers/aws/examples/hello-world/README.md
@@ -0,0 +1,19 @@
+
+
+
+### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/aws/examples/hello-world/)
+
+
+# Hello World Example
+
+Welcome to the Hello World example.
+
+We are excited for you to start your Serverless journey!
+
+* [JavaScript](./node)
+* [Python](./python)
diff --git a/docs/providers/aws/examples/hello-world/node/README.md b/docs/providers/aws/examples/hello-world/node/README.md
new file mode 100644
index 000000000..3ecc656ec
--- /dev/null
+++ b/docs/providers/aws/examples/hello-world/node/README.md
@@ -0,0 +1,35 @@
+
+
+
+### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/aws/examples/hello-world/node/)
+
+
+# Hello World Node.js Example
+
+Make sure `serverless` is installed. [See installation guide](../../../guide/installation.md).
+
+## 1. Deploy
+
+`serverless deploy` or `sls deploy`. `sls` is shorthand for the Serverless CLI command
+
+## 2. Invoke deployed function
+
+`serverless invoke --function helloWorld` or `serverless invoke -f helloWorld`
+
+`-f` is shorthand for `--function`
+
+In your terminal window you should see the response from AWS Lambda
+
+```bash
+{
+ "message": "Hello World",
+ "event": {}
+}
+```
+
+Congrats you have just deployed and ran your Hello World function!
diff --git a/docs/02-providers/aws/examples/hello-world/node/handler.js b/docs/providers/aws/examples/hello-world/node/handler.js
similarity index 95%
rename from docs/02-providers/aws/examples/hello-world/node/handler.js
rename to docs/providers/aws/examples/hello-world/node/handler.js
index 630518208..12a311f42 100644
--- a/docs/02-providers/aws/examples/hello-world/node/handler.js
+++ b/docs/providers/aws/examples/hello-world/node/handler.js
@@ -4,6 +4,7 @@
module.exports.helloWorldHandler = function (event, context, callback) {
const message = {
message: 'Hello World',
+ event,
};
// callback will send message object back
callback(null, message);
diff --git a/docs/02-providers/aws/examples/hello-world/node/serverless.yml b/docs/providers/aws/examples/hello-world/node/serverless.yml
similarity index 100%
rename from docs/02-providers/aws/examples/hello-world/node/serverless.yml
rename to docs/providers/aws/examples/hello-world/node/serverless.yml
diff --git a/docs/providers/aws/examples/hello-world/python/README.md b/docs/providers/aws/examples/hello-world/python/README.md
new file mode 100644
index 000000000..011ee4d61
--- /dev/null
+++ b/docs/providers/aws/examples/hello-world/python/README.md
@@ -0,0 +1,34 @@
+
+
+
+### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/aws/examples/hello-world/python/)
+
+
+# Hello World Python Example
+
+Make sure `serverless` is installed. [See installation guide](../../../guide/installation.md).
+
+## 1. Deploy
+
+`serverless deploy` or `sls deploy`. `sls` is shorthand for the serverless CLI command
+
+## 2. Invoke deployed function
+
+`serverless invoke --function helloWorld` or `serverless invoke -f helloWorld`
+
+`-f` is shorthand for `--function`
+
+In your terminal window you should see the response from AWS Lambda
+
+```bash
+{
+ "message": "Hello World"
+}
+```
+
+Congrats you have just deployed and ran your Hello World function!
diff --git a/docs/02-providers/aws/examples/hello-world/python/handler.py b/docs/providers/aws/examples/hello-world/python/handler.py
similarity index 83%
rename from docs/02-providers/aws/examples/hello-world/python/handler.py
rename to docs/providers/aws/examples/hello-world/python/handler.py
index 690e2d012..7ba5ed97f 100644
--- a/docs/02-providers/aws/examples/hello-world/python/handler.py
+++ b/docs/providers/aws/examples/hello-world/python/handler.py
@@ -3,4 +3,4 @@ def helloWorldHandler(event, context):
'message': 'Hello World'
}
- return message
\ No newline at end of file
+ return message
diff --git a/docs/02-providers/aws/examples/hello-world/python/serverless.yml b/docs/providers/aws/examples/hello-world/python/serverless.yml
similarity index 100%
rename from docs/02-providers/aws/examples/hello-world/python/serverless.yml
rename to docs/providers/aws/examples/hello-world/python/serverless.yml
diff --git a/docs/providers/aws/examples/using-external-libraries/README.md b/docs/providers/aws/examples/using-external-libraries/README.md
new file mode 100644
index 000000000..ff00f2e30
--- /dev/null
+++ b/docs/providers/aws/examples/using-external-libraries/README.md
@@ -0,0 +1,20 @@
+
+
+
+### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/aws/examples/using-external-libraries/)
+
+
+# Using External Libraries Examples
+
+When creating Serverless services you are able to use third party packages from your respective ecosystems package manager. Examples:
+
+* [JavaScript](./node)
+
+For Node.js you can leverage the vast ecosystem of NPM and `require` in modules into your project.
+
+For Python you can use the `pip` package manager.
diff --git a/docs/providers/aws/examples/using-external-libraries/node/README.md b/docs/providers/aws/examples/using-external-libraries/node/README.md
new file mode 100644
index 000000000..df5eddd8b
--- /dev/null
+++ b/docs/providers/aws/examples/using-external-libraries/node/README.md
@@ -0,0 +1,36 @@
+
+
+
+### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/aws/examples/using-external-libraries/node/)
+
+
+# Using External libraries in Node.js Example
+
+Make sure `serverless` is installed. [See installation guide](../../../guide/installation.md).
+
+## 1. Install dependencies
+
+For this example we are going to install the `faker` module from npm.
+
+`npm install faker --save`
+
+## 2. Install the faker module in your `handler.js` file
+
+Inside of `handler.js` require your module:
+
+`const faker = require('faker');`
+
+## 3. Deploy
+
+Run `serverless deploy`.
+
+Alternatively, you can run `npm run deploy` and deploy via NPM script defined in the `package.json` file
+
+## 4. Invoke
+
+`serverless invoke --function helloRandomName`
diff --git a/docs/providers/aws/examples/using-external-libraries/node/event.json b/docs/providers/aws/examples/using-external-libraries/node/event.json
new file mode 100644
index 000000000..2ac50a459
--- /dev/null
+++ b/docs/providers/aws/examples/using-external-libraries/node/event.json
@@ -0,0 +1,5 @@
+{
+ "key3": "value3",
+ "key2": "value2",
+ "key1": "value1"
+}
diff --git a/docs/providers/aws/examples/using-external-libraries/node/handler.js b/docs/providers/aws/examples/using-external-libraries/node/handler.js
new file mode 100644
index 000000000..7d1309b25
--- /dev/null
+++ b/docs/providers/aws/examples/using-external-libraries/node/handler.js
@@ -0,0 +1,13 @@
+// 'use strict';
+// // Import faker module from node_modules
+// const faker = require('faker');
+//
+// // Your function handler
+// module.exports.helloRandomNameHandler = function (event, context, callback) {
+// const randomName = faker.name.firstName();
+// const message = {
+// message: 'Hello ' + randomName,
+// event: event
+// };
+// callback(null, message);
+// };
diff --git a/docs/02-providers/aws/examples/using-external-libraries/node/package.json b/docs/providers/aws/examples/using-external-libraries/node/package.json
similarity index 59%
rename from docs/02-providers/aws/examples/using-external-libraries/node/package.json
rename to docs/providers/aws/examples/using-external-libraries/node/package.json
index a7cd0f3af..89667c7c2 100644
--- a/docs/02-providers/aws/examples/using-external-libraries/node/package.json
+++ b/docs/providers/aws/examples/using-external-libraries/node/package.json
@@ -1,7 +1,10 @@
{
- "name": "external-library",
- "description": "Serverless using external libraries example with Node.js",
+ "name": "hello-world",
+ "description": "Serverless using external libraries example with node",
"private": true,
+ "scripts": {
+ "deploy": "serverless deploy"
+ },
"dependencies": {
"faker": "^3.1.0"
}
diff --git a/docs/02-providers/aws/examples/using-external-libraries/node/serverless.yml b/docs/providers/aws/examples/using-external-libraries/node/serverless.yml
similarity index 56%
rename from docs/02-providers/aws/examples/using-external-libraries/node/serverless.yml
rename to docs/providers/aws/examples/using-external-libraries/node/serverless.yml
index 4bbb504b2..ae8c48d3e 100644
--- a/docs/02-providers/aws/examples/using-external-libraries/node/serverless.yml
+++ b/docs/providers/aws/examples/using-external-libraries/node/serverless.yml
@@ -1,5 +1,5 @@
# Hello Random Name for AWS Lambda
-service: external-lib # Service Name
+service: hello-random-name # Service Name
provider:
name: aws
@@ -7,4 +7,4 @@ provider:
functions:
helloRandomName:
- handler: handler.helloRandomName
+ handler: handler.helloRandomNameHandler
diff --git a/docs/providers/aws/examples/web-serving-html/README.md b/docs/providers/aws/examples/web-serving-html/README.md
new file mode 100644
index 000000000..4a59d8511
--- /dev/null
+++ b/docs/providers/aws/examples/web-serving-html/README.md
@@ -0,0 +1,18 @@
+
+
+
+### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/aws/examples/web-serving-html/)
+
+
+# Serving HTML through API Gateway Example
+
+These examples illustrate how to hookup an API Gateway endpoint to a Lambda function to render HTML on a `GET` request. So instead of returning the default `json` from requests to an endpoint, you can display custom HTML.
+
+This is useful for dynamic webpages and landing pages for marketing activities.
+
+* [JavaScript](./node)
diff --git a/docs/providers/aws/examples/web-serving-html/node/README.md b/docs/providers/aws/examples/web-serving-html/node/README.md
new file mode 100644
index 000000000..b423e4000
--- /dev/null
+++ b/docs/providers/aws/examples/web-serving-html/node/README.md
@@ -0,0 +1,13 @@
+
+
+
+### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/aws/examples/web-serving-html/node/)
+
+
+# Serving HTML in Node.js through API Gateway Example
+
+[This is an example](https://github.com/serverless/serverless/tree/master/docs/providers/aws/examples/web-serving-html/node) of serving vanilla HTML/CSS/JS through API Gateway.
diff --git a/docs/02-providers/aws/examples/web-serving-html/node/handler.js b/docs/providers/aws/examples/web-serving-html/node/handler.js
similarity index 91%
rename from docs/02-providers/aws/examples/web-serving-html/node/handler.js
rename to docs/providers/aws/examples/web-serving-html/node/handler.js
index 914016966..c6566a607 100644
--- a/docs/02-providers/aws/examples/web-serving-html/node/handler.js
+++ b/docs/providers/aws/examples/web-serving-html/node/handler.js
@@ -1,7 +1,7 @@
'use strict';
// Your function handler
-module.exports.staticHtml = function (event, context, callback) {
+module.exports.html = function (event, context, callback) {
let dynamicHtml;
/* check for GET params and use if available */
if (event.queryStringParameters && event.queryStringParameters.name) {
diff --git a/docs/02-providers/aws/examples/web-serving-html/node/serverless.yml b/docs/providers/aws/examples/web-serving-html/node/serverless.yml
similarity index 86%
rename from docs/02-providers/aws/examples/web-serving-html/node/serverless.yml
rename to docs/providers/aws/examples/web-serving-html/node/serverless.yml
index 097ced5e3..26bf00615 100644
--- a/docs/02-providers/aws/examples/web-serving-html/node/serverless.yml
+++ b/docs/providers/aws/examples/web-serving-html/node/serverless.yml
@@ -1,5 +1,4 @@
# Serving HTML through API Gateway for AWS Lambda
-
service: serve-html
provider:
@@ -8,7 +7,7 @@ provider:
functions:
staticHtml:
- handler: handler.staticHtml
+ handler: handler.html
events:
- http:
method: get
diff --git a/docs/providers/aws/guide/README.md b/docs/providers/aws/guide/README.md
new file mode 100644
index 000000000..81f9992c6
--- /dev/null
+++ b/docs/providers/aws/guide/README.md
@@ -0,0 +1,17 @@
+
+
+
+### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/aws/guide/)
+
+
+# Serverless AWS Lambda Guide
+
+Welcome to the Serverless AWS Lambda Guide! Please select a section on the left to get started.
+
+**Note:** Before continuing [AWS system credentials](https://serverless.com/framework/docs/providers/aws/guide/credentials/) are required for using the CLI.
+
+If you have questions, join the [chat in gitter](https://gitter.im/serverless/serverless) or [post over on the forums](https://gitter.im/serverless/serverless)
diff --git a/docs/providers/aws/guide/credentials.md b/docs/providers/aws/guide/credentials.md
new file mode 100644
index 000000000..06e68cf28
--- /dev/null
+++ b/docs/providers/aws/guide/credentials.md
@@ -0,0 +1,112 @@
+
+
+
+### [Read this on the main serverless docs site](https://www.serverless.com/framework/docs/providers/aws/guide/credentials)
+
+
+# Credentials
+
+The Serverless Framework needs access to your cloud providers account so that it can create and manage resources on your behalf.
+
+Here we'll provide setup instructions for different cloud provider accounts. Just pick the one for your provider and follow the steps to get everything in place for Serverless.
+
+At this time, the Serverless Framework supports only Amazon Web Services, but support for other providers is in the works.
+
+## Amazon Web Services
+
+**[Video Guide Available Here](https://www.youtube.com/watch?v=bFHmgqbAh4M)**
+
+Here's how to set up the Serverless Framework with your Amazon Web Services account.
+
+If you're new to Amazon Web Services, make sure you put in a credit card. If you don't have a credit card set up, you may not be able to deploy your resources and you may run into this error:
+
+```bash
+AWS Access Key Id needs a subscription for the service
+```
+
+Don't worry, you won't be charged for signing up. New AWS users get access to the [AWS Free Tier](https://aws.amazon.com/free/), which let's you use many AWS resources for free for 1 year, like [AWS Lambda](https://aws.amazon.com/lambda/pricing/).
+
+While in the AWS Free Tier, you can build an entire application on AWS Lambda, AWS API Gateway, and more, without getting charged for 1 year... As long as you don't exceed the resources in the Free Tier.
+
+### Creating AWS Access Keys
+
+To let the Serverless Framework access your AWS account, we're going to create an IAM User with Admin access, which can configure the services in your AWS account. This IAM User will have its own set of AWS Access Keys.
+
+**Note:** In a production environment, we recommend reducing the permissions to the IAM User which the Framework uses. Unfortunately, the Framework's functionality is growing so fast, we can't yet offer you a finite set of permissions it needs (we're working on this). Consider using a separate AWS account in the interim, if you cannot get permission to your organization's primary AWS accounts.
+
+1. Create or login to your Amazon Web Services Account and go to the Identity & Access Management (IAM) page.
+
+2. Click on **Users** and then **Create New Users**. Enter a name in the first field to remind you this User is the Framework, like `serverless-admin`. Then click **Create**. Later, you can create different IAM Users for different apps and different stages of those apps. That is, if you don't use separate AWS accounts for stages/apps, which is most common.
+
+3. View and copy the **API Key** & **Secret** to a temporary place. You'll need it in the next step.
+
+4. In the User record in the AWS IAM Dashboard, look for **Managed Policies** on the **Permissions** tab and click **Attach Policy**.
+
+5. In the next screen, search for and select **AdministratorAccess** then click **Attach**.
+
+### Using AWS Access Keys
+
+You can configure the Serverless Framework to use your AWS **API Key** & **Secret** two ways:
+
+#### Quick Setup
+
+As a quick setup to get started you can export them as environment variables so they would be accessible to Serverless and the AWS SDK in your shell:
+
+```bash
+export AWS_ACCESS_KEY_ID=