-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
123 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
### Example: Delimiters | ||
|
||
This example demonstrates the usage of **serverless-enhanced-config** with [*custom delimiters*](https://github.com/janl/mustache.js#custom-delimiters). | ||
|
||
`serverless.yml` is used as an entry point for the Serverless Framework and **serverless-enhanced-config**, including: | ||
- `service` and `provider` sections, which are mandatory in the Serverless Framework | ||
- `serverless-enhanced-config` in the plugins section | ||
- `custom.enhancedConfig`, containing in specific **serverless-enhanced-config** settings: | ||
- The configuration template path at `template` | ||
- Variables to be replaced in the template under `variables` | ||
- Partials file paths under `partials` | ||
- Custom delimiters under `delimiters` | ||
|
||
The *actual* serverless configuration to be used by the Serverless Framework will be generated in runtime. You can easily check that with the `print` command. | ||
|
||
Try it with `npm`: | ||
``` | ||
$ git clone https://github.com/aielo/serverless-enhanced-config.git | ||
$ cd serverless-enhanced-config/examples/delimiters/ | ||
$ npm install serverless -g | ||
$ npm install | ||
$ sls print | ||
``` | ||
or `yarn`: | ||
``` | ||
... | ||
$ yarn global add serverless | ||
$ yarn install | ||
$ sls print | ||
``` | ||
|
||
For debugging output, use `SLS_EC_DEBUG`: | ||
``` | ||
$ SLS_EC_DEBUG=1 sls print | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Resources: | ||
GatewayResponseDefault4XX: | ||
Type: 'AWS::ApiGateway::GatewayResponse' | ||
Properties: | ||
ResponseParameters: | ||
gatewayresponse.header.Access-Control-Allow-Origin: "'*'" | ||
gatewayresponse.header.Access-Control-Allow-Headers: "'*'" | ||
ResponseType: DEFAULT_4XX | ||
RestApiId: | ||
Ref: 'ApiGatewayRestApi' | ||
GatewayResponseDefault5XX: | ||
Type: 'AWS::ApiGateway::GatewayResponse' | ||
Properties: | ||
ResponseParameters: | ||
gatewayresponse.header.Access-Control-Allow-Origin: "'*'" | ||
gatewayresponse.header.Access-Control-Allow-Headers: "'*'" | ||
ResponseType: DEFAULT_5XX | ||
RestApiId: | ||
Ref: 'ApiGatewayRestApi' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"name": "serverless-enhanced-config-delimiters", | ||
"version": "0.1.0", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"author": "", | ||
"license": "ISC", | ||
"dependencies": { | ||
"serverless-dotenv-plugin": "^2.3.2" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[[ function.name ]]: | ||
handler: [[ function.handler ]] | ||
events: | ||
- http: | ||
path: [[ function.path ]] | ||
method: [[ function.method ]] | ||
cors: [[ function.cors ]] | ||
authorizer: aws_iam |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
functions: | ||
[[> function ]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
plugins: | ||
- serverless-dotenv-plugin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
service: delimiters | ||
|
||
plugins: | ||
- ../.. | ||
|
||
provider: | ||
name: aws | ||
|
||
custom: | ||
enhancedConfig: | ||
template: template.yml | ||
variables: | ||
service: delimiters | ||
function: | ||
name: myfunc | ||
handler: handlers/myfunc.main | ||
path: mypath/myfunc | ||
method: get | ||
cors: true | ||
partials: | ||
plugins: partials/plugins.yml | ||
functions: partials/functions.yml | ||
function: partials/function.yml | ||
delimiters: | ||
- '[[' | ||
- ']]' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
service: [[ service ]] | ||
|
||
package: | ||
individually: true | ||
|
||
[[> plugins ]] | ||
|
||
provider: | ||
name: aws | ||
runtime: nodejs12.x | ||
stage: ${opt:stage, env:stage, 'dev'} | ||
region: ${opt:region, env:region, 'us-east-1'} | ||
|
||
[[> functions ]] | ||
|
||
resources: | ||
- ${file(includes/api-gateway.yml)} |