![Maven Central Adds Sigstore Signature Validation](https://cdn.sanity.io/images/cgdhsj6q/production/7da3bc8a946cfb5df15d7fcf49767faedc72b483-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Maven Central Adds Sigstore Signature Validation
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
serverless-fragments
Advanced tools
A node.js template processor for creating reusable [serverless](https://serverless.com/) fragments.
A node.js template processor for creating reusable serverless fragments.
The engine loads a specified top-level yaml file recursively and resolves template placeholders.
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:
module.exports = slsFragments.load(path.join(__dirname, 'serverless/serverless.core.yml', new Map[['version':'1.0.1']]));
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:
}
:
,
=
tfile supports referencing json files, which are automatically converted to yaml if their extension is .json
This might be useful to keep configuration files as json and easily reuse them with the code,
as many languages support JSON natively, unlike yaml.
config
├── local.json
└── dev.json
└── test.json
└── stage.json
└── prod.json
custom:
${tfile:config/${opt:stage}.json}
Syntax: tfile:[file path]:[parameters]
, where
Usage:
${tfile:iamRoleStatements/dynamoDbFull.yml}
${tfile:iamRoleStatements/dynamoDbFull.yml:tableName=entity}
${tfile:resources/sqsQueue.yml:
visibilityTimeout=60,
delaySeconds=10
}
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], [default value]
or custom:[variable name], [default value]
, where
Usage:
${opt:stage}
${self:service.name}
${self:service.name}-${opt:stage}
${self:${opt:env}.tableName}
Use # for line comments, anything between the # and end of line will be skipped from processing
Usage:
# ${tfile:iamRoleStatements/dynamoDbFull.yml:tableName=entity}
# full entity table and all it's indexes access for the lambda
├── package.json
├── serverless.js
├── serverless
│ ├── serverless.core.yml
│ ├── provider
│ │ └── nodejs.yml
│ ├── resources
│ │ └── sqsQueue.yml
package.json
"devDependencies": {
"serverless-fragments": "^2.0.0"
}
serverless.js
const path = require('path');
const slsFragments = require('serverless-fragments');
module.exports = slsFragments.load(path.join(__dirname, 'serverless/serverless.core.yml', new Map([['version', '1.0.0']])));
serverless.core.yml
# entityService AWS serices definition
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}}
${opt:stage, 'dev'}
FAQs
A node.js template processor for creating reusable [serverless](https://serverless.com/) fragments.
The npm package serverless-fragments receives a total of 21 weekly downloads. As such, serverless-fragments popularity was classified as not popular.
We found that serverless-fragments 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
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.