mirror of
https://github.com/serverless/serverless.git
synced 2026-01-18 14:58:43 +00:00
Add CloudWatchEvent rule name and description fields
This commit is contained in:
parent
ee19ce6609
commit
fdb5407b5e
@ -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'
|
||||
|
||||
@ -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}",` : ''}
|
||||
|
||||
@ -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: {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user