diff --git a/lib/event_sources.json.example b/lib/event_sources.json.example index 1b2d7936..d95bd4a9 100644 --- a/lib/event_sources.json.example +++ b/lib/event_sources.json.example @@ -11,7 +11,12 @@ { "ScheduleName": "node-lambda-test-schedule", "ScheduleState": "ENABLED", - "ScheduleExpression": "rate(1 hour)" + "ScheduleExpression": "rate(1 hour)", + "Input": + { + "key1": "value", + "key2": "value" + } } ] } diff --git a/lib/schedule_events.js b/lib/schedule_events.js index 1c6ac503..ac40db84 100644 --- a/lib/schedule_events.js +++ b/lib/schedule_events.js @@ -71,7 +71,8 @@ class ScheduleEvents { Rule: params.ScheduleName, Targets: [{ Arn: params.FunctionArn, - Id: this._functionName(params) + Id: this._functionName(params), + Input: params.hasOwnProperty('Input') ? JSON.stringify(params.Input) : '' }] } } diff --git a/test/main.js b/test/main.js index f5782e3f..0bccc7d3 100644 --- a/test/main.js +++ b/test/main.js @@ -814,7 +814,11 @@ describe('lib/main', function () { ScheduleEvents: [{ ScheduleName: 'node-lambda-test-schedule', ScheduleState: 'ENABLED', - ScheduleExpression: 'rate(1 hour)' + ScheduleExpression: 'rate(1 hour)', + Input: { + key1: 'value', + key2: 'value' + } }] } assert.deepEqual(lambda._eventSourceList(program), expected) diff --git a/test/schedule_events.js b/test/schedule_events.js index 1003a4cd..b5e8ab1a 100644 --- a/test/schedule_events.js +++ b/test/schedule_events.js @@ -121,16 +121,32 @@ describe('lib/schedule_events', () => { }) describe('_putTargetsParams', () => { - it('correct value', () => { + it('correct value (No "Input" setting)', () => { const expected = { Rule: 'node-lambda-test-schedule', Targets: [{ Arn: 'arn:aws:lambda:us-west-2:XXX:function:node-lambda-test-function', - Id: 'node-lambda-test-function' + Id: 'node-lambda-test-function', + Input: '' }] } assert.deepEqual(schedule._putTargetsParams(params), expected) }) + + it('correct value ("Input" setting)', () => { + const expected = { + Rule: 'node-lambda-test-schedule', + Targets: [{ + Arn: 'arn:aws:lambda:us-west-2:XXX:function:node-lambda-test-function', + Id: 'node-lambda-test-function', + Input: '{"key":"value"}' + }] + } + assert.deepEqual( + schedule._putTargetsParams(Object.assign({Input: {key: 'value'}}, params)), + expected + ) + }) }) describe('_putRule', () => {