Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More β†’
Socket
Sign inDemoInstall
Socket

serverless-step-functions

Package Overview
Dependencies
Maintainers
2
Versions
131
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

serverless-step-functions - npm Package Compare versions

Comparing version 2.30.0 to 2.31.0

.github/workflows/config.yml

4

lib/deploy/events/cloudWatchEvent/compileCloudWatchEventEvents.js

@@ -46,3 +46,3 @@ 'use strict';

Name = eventRule.name;
EventBusName = eventRule.eventBusName;
EventBusName = JSON.stringify(eventRule.eventBusName);
IamRole = eventRule.iamRole;

@@ -88,3 +88,3 @@

"Properties": {
${EventBusName ? `"EventBusName": "${EventBusName}",` : ''}
${EventBusName ? `"EventBusName": ${EventBusName},` : ''}
"EventPattern": ${EventPattern.replace(/\\n|\\r/g, '')},

@@ -91,0 +91,0 @@ "State": "${State}",

@@ -300,2 +300,32 @@ 'use strict';

itParam('should respect eventBusName intrinsic function', ['cloudwatchEvent', 'eventBridge'], (source) => {
serverlessStepFunctions.serverless.service.stepFunctions = {
stateMachines: {
first: {
events: [
{
[source]: {
event: {
source: ['aws.ec2'],
'detail-type': ['EC2 Instance State-change Notification'],
detail: { state: ['pending'] },
},
enabled: false,
input: '{"key":"value"}',
name: 'test-event-name',
eventBusName: '{"Fn::If": [isLocal, "develop", "production"}',
},
},
],
},
},
};
serverlessStepFunctions.compileCloudWatchEventEvents();
expect(serverlessStepFunctions.serverless.service
.provider.compiledCloudFormationTemplate.Resources.FirstEventsRuleCloudWatchEvent1
.Properties.EventBusName).to.equal('{"Fn::If": [isLocal, "develop", "production"}');
});
itParam('should respect input variable as an object', ['cloudwatchEvent', 'eventBridge'], (source) => {

@@ -302,0 +332,0 @@ serverlessStepFunctions.serverless.service.stepFunctions = {

@@ -318,2 +318,22 @@ 'use strict';

function getEventBridgePermissions(state) {
const eventBuses = new Set();
for (const entry of state.Parameters.Entries) {
eventBuses.add(entry.EventBusName || 'default');
}
return [
{
action: 'events:PutEvents',
resource: [...eventBuses].map(eventBus => ({
'Fn::Sub': [
'arn:aws:events:${AWS::Region}:${AWS::AccountId}:event-bus/${eventBus}',
{ eventBus },
],
})),
},
];
}
// if there are multiple permissions with the same action, then collapsed them into one

@@ -406,2 +426,6 @@ // permission instead, and collect the resources into an array

case 'arn:aws:states:::events:putEvents':
case 'arn:aws:states:::events:putEvents.waitForTaskToken':
return getEventBridgePermissions(state);
default:

@@ -408,0 +432,0 @@ if (isIntrinsic(state.Resource) || state.Resource.startsWith('arn:aws:lambda')) {

@@ -61,3 +61,3 @@ 'use strict';

obj[key] = `\${${paramName}}`;
yield [paramName, value];
yield [paramName, value, (obj.Type === 'Wait' && key === 'Seconds')];
} else if (typeof value === 'object') {

@@ -148,2 +148,12 @@ const innerFuncs = Array.from(getIntrinsicFunctions(value));

const f = translateLocalFunctionNames.bind(this);
let processedDefinitionString = definitionString;
functionMappings.forEach((functionMapping) => {
if (functionMapping[2]) {
processedDefinitionString = processedDefinitionString.replace(
// eslint-disable-next-line no-useless-escape
new RegExp(`\\\"(\\\$\\\{${functionMapping[0]}\\\})\\\"`, 'g'),
'$1',
);
}
});
const params = _.fromPairs(functionMappings.map(([k, v]) => [k, f(v)]));

@@ -153,3 +163,3 @@

'Fn::Sub': [
definitionString,
processedDefinitionString,
params,

@@ -161,3 +171,2 @@ ],

}
if (stateMachineObj.useExactVersion === true && DefinitionString['Fn::Sub']) {

@@ -164,0 +173,0 @@ const params = DefinitionString['Fn::Sub'][1];

@@ -373,2 +373,108 @@ 'use strict';

it('should use raw values for Seconds for Wait task', () => {
const definition = {
Comment: 'Hello World',
StartAt: 'HelloWorld',
States: {
HelloWorld: {
Type: 'Wait',
Seconds: { Ref: 'SomeSeconds' },
End: true,
},
},
};
serverless.service.stepFunctions = {
stateMachines: {
myStateMachine1: {
name: 'stateMachineBeta1',
definition,
},
},
};
serverlessStepFunctions.compileStateMachines();
const actual = serverlessStepFunctions
.serverless
.service
.provider
.compiledCloudFormationTemplate
.Resources
.StateMachineBeta1
.Properties
.DefinitionString;
expect(actual['Fn::Sub'][0]).to.equal(`
{
"Comment": "Hello World",
"StartAt": "HelloWorld",
"States": {
"HelloWorld": {
"Type": "Wait",
"Seconds": \${4dfb8832166d083d5c26a32fbfcaebf9},
"End": true
}
}
}
`.trim());
});
it('should not use raw values for Seconds in other task', () => {
const definition = {
Comment: 'Hello World',
StartAt: 'HelloWorld',
States: {
HelloWorld: {
Type: 'Task',
Resource: 'arn:aws:states:::glue:startJobRun.sync',
Parameters: {
Seconds: { Ref: 'SomeSeconds' },
},
TimeoutSecondsPath: '$.params.maxTime',
HeartbeatSecondsPath: '$.params.heartbeat',
End: true,
},
},
};
serverless.service.stepFunctions = {
stateMachines: {
myStateMachine1: {
name: 'stateMachineBeta1',
definition,
},
},
};
serverlessStepFunctions.compileStateMachines();
const actual = serverlessStepFunctions
.serverless
.service
.provider
.compiledCloudFormationTemplate
.Resources
.StateMachineBeta1
.Properties
.DefinitionString;
expect(actual['Fn::Sub'][0]).to.equal(`
{
"Comment": "Hello World",
"StartAt": "HelloWorld",
"States": {
"HelloWorld": {
"Type": "Task",
"Resource": "arn:aws:states:::glue:startJobRun.sync",
"Parameters": {
"Seconds": "\${4dfb8832166d083d5c26a32fbfcaebf9}"
},
"TimeoutSecondsPath": "$.params.maxTime",
"HeartbeatSecondsPath": "$.params.heartbeat",
"End": true
}
}
}
`.trim());
});
it('should add dependsOn resources', () => {

@@ -375,0 +481,0 @@ serverless.service.stepFunctions = {

@@ -80,2 +80,3 @@ 'use strict';

required: true,
type: 'string',
},

@@ -85,2 +86,3 @@ data: {

shortcut: 'd',
type: 'string',
},

@@ -91,2 +93,3 @@ path: {

shortcut: 'p',
type: 'string',
},

@@ -96,2 +99,3 @@ stage: {

shortcut: 's',
type: 'string',
},

@@ -101,2 +105,3 @@ region: {

shortcut: 'r',
type: 'string',
},

@@ -103,0 +108,0 @@ },

{
"name": "serverless-step-functions",
"version": "2.30.0",
"version": "2.31.0",
"description": "The module is AWS Step Functions plugin for Serverless Framework",

@@ -42,3 +42,3 @@ "main": "lib/index.js",

"nyc": "^15.0.0",
"semantic-release": "^17.4.2",
"semantic-release": "^17.2.3",
"serverless": "^1.72.0",

@@ -49,3 +49,3 @@ "sinon": "^1.17.5"

"@hapi/joi": "^15.0.2",
"asl-validator": "^1.8.0",
"asl-validator": "^1.9.8",
"bluebird": "^3.4.0",

@@ -52,0 +52,0 @@ "chalk": "^1.1.1",

# Serverless Step Functions
[![serverless](http://public.serverless.com/badges/v3.svg)](http://www.serverless.com) [![Build Status](https://travis-ci.org/serverless-operations/serverless-step-functions.svg?branch=master)](https://travis-ci.org/serverless-operations/serverless-step-functions) [![npm version](https://badge.fury.io/js/serverless-step-functions.svg)](https://badge.fury.io/js/serverless-step-functions) [![Coverage Status](https://coveralls.io/repos/github/horike37/serverless-step-functions/badge.svg?branch=master)](https://coveralls.io/github/horike37/serverless-step-functions?branch=master) [![MIT License](http://img.shields.io/badge/license-MIT-blue.svg?style=flat)](LICENSE) [![serverless-step-functions Dev Token](https://badge.devtoken.rocks/serverless-step-functions)](https://devtoken.rocks/package/serverless-step-functions)
[![serverless](http://public.serverless.com/badges/v3.svg)](http://www.serverless.com) ![CI](https://github.com/serverless-operations/serverless-step-functions/actions/workflows/config.yml/badge.svg) [![npm version](https://badge.fury.io/js/serverless-step-functions.svg)](https://badge.fury.io/js/serverless-step-functions) [![Coverage Status](https://coveralls.io/repos/github/horike37/serverless-step-functions/badge.svg?branch=master)](https://coveralls.io/github/horike37/serverless-step-functions?branch=master) [![MIT License](http://img.shields.io/badge/license-MIT-blue.svg?style=flat)](LICENSE) [![serverless-step-functions Dev Token](https://badge.devtoken.rocks/serverless-step-functions)](https://devtoken.rocks/package/serverless-step-functions)

@@ -5,0 +5,0 @@ This is the Serverless Framework plugin for AWS Step Functions.

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚑️ by Socket Inc