Security News
Opengrep Emerges as Open Source Alternative Amid Semgrep Licensing Controversy
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
reusable-serverless-template
Advanced tools
A node.js template processor for creating reusable [serverless](https://serverless.com/) resources or configuration fragments.
A node.js template processor for creating reusable serverless resources or configuration fragments.
The engine loads a specified top-level yaml file recursively and resolves template placeholders. tfile loads nested template files. Parameters passed to tfile are matched against serverless variables-style placeholders ${custom:var-name} and ${opt:var-name} in the nested file.
A top level file as well as nested files do not need to be valid yaml objects, only the final structure, after the processing is done, has to be. This allows a flexibility to define partial yaml arrays or objects which can be merged into a parent file.
The final yaml object is loaded using js-yaml
Loaded yaml object can be thus exported and processed by serverless framework:
const template = require('reusable-serverless-template');
const serverlessYaml = template.load(path.join(__dirname, 'serverless/serverless.core.yml', new Map[['foo':'bar']]));
module.exports = serverlessYaml;
A scope of the parameters passed to template#load function, as well as tfile parameters, is the parent file only. There are not propagated to nested templates to avoid bugs related to missing nested template parameters, which are wrongly resolved by parent parameters.
Loads the specified file recursively and apply parameters to matched variables names specified using opt, and custom placeholders.
Avoid using the following reserved characters for:
}
:
,
=
Syntax: tfile:[file path]:[parameters]
, where
Usage:
${tfile:iamRoleStatements/dynamoDbFull.yml}
${tfile:iamRoleStatements/dynamoDbFull.yml:tableName=entity}
Variables names specified using these placeholders are replaced with parameters passed from template#load function in top level file or tfile in nested templates
Syntax: opt:[variable name]
or custom:[variable name]
, where
Usage:
${opt:foo}
${custom:foo.bar}
${opt:foo}-${opt:bar}
${self:custom.tableName${opt:env}}
├── serverless.js
├── serverless
│ ├── serverless.core.yml
│ ├── provider
│ │ └── nodejs.yml
│ ├── resources
│ │ └── sqsQueue.yml
serverless.js
const path = require('path');
const template = require('reusable-serverless-template');
const serverlessYaml = template.load(path.join(__dirname, 'serverless/serverless.core.yml', new Map([['version', '1.0.0']])));
module.exports = serverlessYaml;
serverless.core.yml
service: entityService
provider:
${tfile:provider/nodejs.yml}
environment:
ENV: ${self:provider.stage}
VERSION: ${opt:version}
functions:
createEntity:
handler: dist/src/entityRestHandler.create
events:
- http:
path: /entity
method: post
resources:
Resources:
${tfile:resources/sqsQueue.yml:queueName=entity}
provider/nodejs.yml
name: aws
runtime: nodejs8.10
stage: ${opt:stage, 'dev'}
region: ${opt:region, 'ap-southeast-2'}
memorySize: 512
resources/sqsQueue.yml
${opt:queueName}Queue:
Type: "AWS::SQS::Queue"
Properties:
QueueName: ${opt:queueName}Queue
Use standard serverless command to use the serverless.js file e.g.
sls package --stage dev --region ap-southeast-2 -v
${self:custom.tableName${opt:env}}
FAQs
**This package has been renamed to [serverless-fragments](https://www.npmjs.com/package/serverless-fragments)**
We found that reusable-serverless-template demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.