Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
@serverless/template
Advanced tools
This component is used behind the scenes to deploy your YAML templates. It is loaded by the serverless CLI and executed just as any other component. However, there's a lot you can do with this component programmatically. See the sections below for some ex
Readme
This component is used behind the scenes to deploy your YAML templates. It is loaded by the serverless CLI and executed just as any other component. However, there's a lot you can do with this component programmatically. See the sections below for some examples.
To deploy to multiple environments you must utilize the programmatic API, via serverless.js
file.
serverless.js
const { Component } = require('@serverless/core')
class Deploy extends Component {
async default(inputs = {}) {
const { env } = inputs
const template = await this.load('@serverless/template', env)
return await template({ template: __dirname + '/serverless.yml' })
}
async remove(inputs = {}) {
const { env } = inputs
const template = await this.load('@serverless/template', env)
await template.remove(inputs)
}
}
module.exports = Deploy
serverless.yml
name: test
lambda:
component: '@serverless/function'
inputs:
name: my-function
description: My Serverless Function
memory: 128
timeout: 20
code: './code'
hanlder": 'handler.handler'
region: us-east-1
runtime: nodejs10.x
Invoking sls --env=dev
will result in state files in .serverless/
being prefixed with the value of your env
:
Deploy.dev.json
, etc. That way you can deploy unlimited environments, add pre/post processing, load whatever .env
you need, etc.
A template itself does not contain any methods so custom methods are executed on the specific template aliases.
sls install --component lambda
will load the lambda
alias from your template, instantiate the corresponding component, and execute the install
method passing in the inputs you specify via CLI parameters.
Inputs from the template itself are not passed as they can not be interpreted/resolved without running the entire template.
You can pass as many --component
parameters as you need.
serverless.js
const { Component } = require('@serverless/core')
class Deploy extends Component {
/* ...skipped default method for brevity ... */
async install(inputs = {}) {
const template = await this.load('@serverless/template')
await template.install({ template: __dirname + '/serverless.yml', ...inputs })
}
}
module.exports = Deploy
When invoking methods on a template
instance, you always need to pass in a path to the template file or a template object.
Running sls install --component lambda --debug
- this will load the template, find the lambda
alias, and invoke the install
method on the instance of the component.
Visit our github and file an issue with as much info as possible about your problem. If you think you've found a bug - please do post a complete reproduction repo. It will help us and our contributors to help you much faster.
FAQs
This component is used behind the scenes to deploy your YAML templates. It is loaded by the serverless CLI and executed just as any other component. However, there's a lot you can do with this component programmatically. See the sections below for some ex
The npm package @serverless/template receives a total of 130,158 weekly downloads. As such, @serverless/template popularity was classified as popular.
We found that @serverless/template demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 7 open source maintainers 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.