Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aws cloudwatchEvent event schema #8230

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 23 additions & 1 deletion lib/plugins/aws/package/compile/events/cloudWatchEvent/index.js
Expand Up @@ -11,9 +11,31 @@ class AwsCompileCloudWatchEventEvents {
'package:compileEvents': this.compileCloudWatchEventEvents.bind(this),
};

// TODO: Complete schema, see https://github.com/serverless/serverless/issues/8026
this.serverless.configSchemaHandler.defineFunctionEvent('aws', 'cloudwatchEvent', {
type: 'object',
properties: {
event: { type: 'object' },
input: { type: 'string', maxLength: 8192 },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In implementation we support also object type

inputPath: { type: 'string', maxLength: 256 },
inputTransformer: {
type: 'object',
properties: {
inputPathsMap: { type: 'object' },
inputTemplates: { type: 'string', maxLength: 8192 },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be inputTemplate.

Also we're relying on same configuration in case of eventBridge event. It'll be nice to have both schemas matching.

See:

this.serverless.configSchemaHandler.defineFunctionEvent('aws', 'eventBridge', {
type: 'object',
properties: {
eventBus: { type: 'string', minLength: 1 },
schedule: { pattern: '^(?:cron|rate)\\(.+\\)$' },
pattern: {
type: 'object',
properties: {
'version': {},
'id': {},
'detail-type': {},
'source': {},
'account': {},
'time': {},
'region': {},
'resources': {},
'detail': {},
},
additionalProperties: false,
},
input: { type: 'object' },
inputPath: { type: 'string', minLength: 1, maxLength: 256 },
inputTransformer: {
type: 'object',
properties: {
inputPathsMap: {
type: 'object',
additionalProperties: { type: 'string', minLength: 1 },
},
inputTemplate: { type: 'string', minLength: 1, maxLength: 8192 },
},
required: ['inputTemplate'],
additionalProperties: false,
},
},
allOf: [
{ anyOf: [{ required: ['pattern'] }, { required: ['schedule'] }] },
{
oneOf: [
{ required: [] },
{ required: ['input'] },
{ required: ['inputPath'] },
{ required: ['inputTransformer'] },
],
},
],
});
}

},
required: ['inputTemplates'],
additionalProperties: false,
},
description: { type: 'string', maxLength: 512 },
name: { type: 'string', pattern: '[a-zA-Z0-9-_.]+', maxLength: 64 },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's also define minLength

enabled: { type: 'boolean' },
},
oneOf: [
{ required: ['input'] },
{ required: ['inputPath'] },
{ required: ['inputTransformer'] },
Comment on lines +39 to +41
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should also add required: [], as technically we do not require any of this options

],
additionalProperties: false,
});
}

Expand Down