
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
serverless-step-functions
Advanced tools
The module is AWS Step Functions plugin for Serverless Framework
The serverless-step-functions npm package is a Serverless Framework plugin that allows you to define and deploy AWS Step Functions using the Serverless Framework. It simplifies the process of creating, managing, and deploying state machines, which are used to orchestrate complex workflows in AWS.
Define State Machines
This feature allows you to define state machines directly in your serverless.yml file. The code sample shows a simple state machine with a single Pass state that returns 'Hello, World!'.
{
"service": "my-service",
"frameworkVersion": "2",
"plugins": ["serverless-step-functions"],
"provider": {
"name": "aws",
"runtime": "nodejs14.x"
},
"stepFunctions": {
"stateMachines": {
"helloStateMachine": {
"definition": {
"Comment": "A Hello World example of the Amazon States Language using a Pass state",
"StartAt": "HelloWorld",
"States": {
"HelloWorld": {
"Type": "Pass",
"Result": "Hello, World!",
"End": true
}
}
}
}
}
}
}
Deploy State Machines
This feature allows you to deploy your state machines to AWS using the Serverless Framework. The code sample shows a script that can be added to your package.json to deploy your service and state machines.
{
"scripts": {
"deploy": "serverless deploy"
}
}
Invoke State Machines
This feature allows you to invoke state machines from your Lambda functions. The code sample shows a Lambda function that can be triggered via an HTTP POST request to invoke a state machine.
{
"functions": {
"invokeStateMachine": {
"handler": "handler.invokeStateMachine",
"events": [
{
"http": {
"path": "invoke",
"method": "post"
}
}
]
}
}
}
The aws-sdk package is the official AWS SDK for JavaScript. It provides a comprehensive set of tools for interacting with AWS services, including Step Functions. Unlike serverless-step-functions, which is a Serverless Framework plugin, aws-sdk is a general-purpose library that can be used in any Node.js application.
The stepfunctions-local package allows you to run AWS Step Functions locally for development and testing purposes. It provides a local version of the Step Functions service, which can be useful for offline development. This package is more focused on local development, whereas serverless-step-functions is focused on deployment and management in AWS.
Serverless plugin for AWS Step Functions.
This plugin requires Serverless v1.4.0 or later.
Run npm install
in your Serverless project.
$ npm install --save serverless-step-functions
Add the plugin to your serverless.yml file
plugins:
- serverless-step-functions
Specifies your statemachine definition using Amazon States Language in a definition
statement in serverless.yml.
custom:
accountId: xxxxxxxx
functions:
hellofunc:
handler: handler.hello
stepFunctions:
stateMachines:
hellostepfunc1:
events:
- http:
path: gofunction
method: GET
definition:
Comment: "A Hello World example of the Amazon States Language using an AWS Lambda Function"
StartAt: HelloWorld1
States:
HelloWorld1:
Type: Task
Resource: arn:aws:lambda:${opt:region}:${self:custom.accountId}:function:${self:service}-${opt:stage}-hello
End: true
hellostepfunc2:
definition:
StartAt: HelloWorld2
States:
HelloWorld2:
Type: Task
Resource: arn:aws:states:${opt:region}:${self:custom.accountId}:activity:myTask
End: true
activities:
- myTask
- yourTask
To create HTTP endpoints as Event sources for your StepFunctions statemachine
This setup specifies that the hello statemachine should be run when someone accesses the API gateway at hello via a GET request.
Here's an example:
stepFunctions:
stateMachines:
hello:
events:
- http:
path: hello
method: GET
definition:
Here You can define an POST endpoint for the path posts/create.
stepFunctions:
stateMachines:
hello:
events:
- http:
path: posts/create
method: POST
definition:
You can input an value as json in request body, the value is passed as the input value of your statemachine
$ curl -XPOST https://xxxxxxxxx.execute-api.us-east-1.amazonaws.com/dev/posts/create -d '{"foo":"bar"}'
Runn sls deploy
, the defined Stepfunctions are deployed.
$ sls invoke stepf --name <stepfunctionname> --data '{"foo":"bar"}'
The IAM roles required to run Statemachine are automatically generated. It is also possible to specify ARN directly.
Here's an example:
stepFunctions:
stateMachines:
hello:
role: arn:aws:iam::xxxxxxxx:role/yourRole
definition:
FAQs
The module is AWS Step Functions plugin for Serverless Framework
The npm package serverless-step-functions receives a total of 143,789 weekly downloads. As such, serverless-step-functions popularity was classified as popular.
We found that serverless-step-functions demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.