From 0f1dbbd2d51e225d511d2ff1ad14b14b58bb4bca Mon Sep 17 00:00:00 2001 From: Jeffrey Mohler Date: Mon, 9 Oct 2023 15:44:15 -0500 Subject: [PATCH] feat(EventBridge Scheduler): enable passing input to target --- .../events/schedule/compileScheduledEvents.js | 1 + .../schedule/compileScheduledEvents.test.js | 25 +++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/lib/deploy/events/schedule/compileScheduledEvents.js b/lib/deploy/events/schedule/compileScheduledEvents.js index ee1db6f..2adf70c 100644 --- a/lib/deploy/events/schedule/compileScheduledEvents.js +++ b/lib/deploy/events/schedule/compileScheduledEvents.js @@ -156,6 +156,7 @@ module.exports = { "Target": { "Arn": { "Ref": "${stateMachineLogicalId}" }, "RoleArn": ${roleArn} + ${Input ? `,"Input": "${Input}"` : ''} }, "FlexibleTimeWindow": { "Mode": "OFF" diff --git a/lib/deploy/events/schedule/compileScheduledEvents.test.js b/lib/deploy/events/schedule/compileScheduledEvents.test.js index b5baefd..bf3e7d8 100644 --- a/lib/deploy/events/schedule/compileScheduledEvents.test.js +++ b/lib/deploy/events/schedule/compileScheduledEvents.test.js @@ -512,6 +512,31 @@ describe('#httpValidate()', () => { expect(serverlessStepFunctions.serverless.service.provider.compiledCloudFormationTemplate.Resources.FirstStepFunctionsSchedulerSchedule1.Properties.ScheduleExpressionTimezone).to.equal('Asia/Mumbai'); }); + it('should define input when schedular and input are given', () => { + serverlessStepFunctions.serverless.service.stepFunctions = { + stateMachines: { + first: { + events: [ + { + schedule: { + method: 'scheduler', + rate: 'cron(1 3 * * ? *)', + enabled: false, + timezone: 'Asia/Mumbai', + input: { + key: 'value', + }, + }, + }, + ], + }, + }, + }; + serverlessStepFunctions.compileScheduledEvents(); + + expect(serverlessStepFunctions.serverless.service.provider.compiledCloudFormationTemplate.Resources.FirstStepFunctionsSchedulerSchedule1.Properties.Target.Input).to.equal('{"key":"value"}'); + }); + it('should accept timezone only if method is scheduler', () => { serverlessStepFunctions.serverless.service.stepFunctions = { stateMachines: {