diff --git a/docs/providers/aws/events/schedule.md b/docs/providers/aws/events/schedule.md index 4dc7e6d03..cfbfc62ec 100644 --- a/docs/providers/aws/events/schedule.md +++ b/docs/providers/aws/events/schedule.md @@ -34,6 +34,8 @@ functions: handler: statistics.handler events: - schedule: + name: your-scheduled-rate-event-name + description: 'your scheduled rate event description' rate: rate(10 minutes) enabled: false input: @@ -42,6 +44,8 @@ functions: stageParams: stage: dev - schedule: + name: your-scheduled-cron-event-name + description: 'your scheduled cron event description' rate: cron(0 12 * * ? *) enabled: false inputPath: '$.stageVariables' diff --git a/lib/plugins/aws/deploy/compile/events/schedule/index.js b/lib/plugins/aws/deploy/compile/events/schedule/index.js index a2814f922..72fc42529 100644 --- a/lib/plugins/aws/deploy/compile/events/schedule/index.js +++ b/lib/plugins/aws/deploy/compile/events/schedule/index.js @@ -25,6 +25,8 @@ class AwsCompileScheduledEvents { let State; let Input; let InputPath; + let Name; + let Description; // TODO validate rate syntax if (typeof event.schedule === 'object') { @@ -42,6 +44,8 @@ class AwsCompileScheduledEvents { State = event.schedule.enabled ? 'ENABLED' : 'DISABLED'; Input = event.schedule.input; InputPath = event.schedule.inputPath; + Name = event.schedule.name; + Description = event.schedule.description; if (Input && InputPath) { const errorMessage = [ @@ -88,6 +92,8 @@ class AwsCompileScheduledEvents { "Properties": { "ScheduleExpression": "${ScheduleExpression}", "State": "${State}", + ${Name ? `"Name": "${Name}",` : ''} + ${Description ? `"Description": "${Description}",` : ''} "Targets": [{ ${Input ? `"Input": "${Input}",` : ''} ${InputPath ? `"InputPath": "${InputPath}",` : ''} diff --git a/lib/plugins/aws/deploy/compile/events/schedule/index.test.js b/lib/plugins/aws/deploy/compile/events/schedule/index.test.js index 91eea1e73..de02c20f8 100644 --- a/lib/plugins/aws/deploy/compile/events/schedule/index.test.js +++ b/lib/plugins/aws/deploy/compile/events/schedule/index.test.js @@ -101,6 +101,52 @@ describe('AwsCompileScheduledEvents', () => { ).to.equal('AWS::Lambda::Permission'); }); + it('should respect name variable', () => { + awsCompileScheduledEvents.serverless.service.functions = { + first: { + events: [ + { + schedule: { + rate: 'rate(10 minutes)', + enabled: false, + name: 'your-scheduled-event-name', + }, + }, + ], + }, + }; + + awsCompileScheduledEvents.compileScheduledEvents(); + + expect(awsCompileScheduledEvents.serverless.service + .provider.compiledCloudFormationTemplate.Resources.FirstEventsRuleSchedule1 + .Properties.Name + ).to.equal('your-scheduled-event-name'); + }); + + it('should respect description variable', () => { + awsCompileScheduledEvents.serverless.service.functions = { + first: { + events: [ + { + schedule: { + rate: 'rate(10 minutes)', + enabled: false, + description: 'your scheduled event description', + }, + }, + ], + }, + }; + + awsCompileScheduledEvents.compileScheduledEvents(); + + expect(awsCompileScheduledEvents.serverless.service + .provider.compiledCloudFormationTemplate.Resources.FirstEventsRuleSchedule1 + .Properties.Description + ).to.equal('your scheduled event description'); + }); + it('should respect inputPath variable', () => { awsCompileScheduledEvents.serverless.service.functions = { first: {