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
aws cloudwatchEvent event schema #8230
Conversation
Codecov Report
@@ Coverage Diff @@
## master #8230 +/- ##
==========================================
- Coverage 88.16% 88.09% -0.07%
==========================================
Files 248 248
Lines 9430 9376 -54
==========================================
- Hits 8314 8260 -54
Misses 1116 1116
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @thewizarodofoz
It looks good! Please see my remarks, also let's remove corresponding inline validation
this.serverless.configSchemaHandler.defineFunctionEvent('aws', 'cloudwatchEvent', { | ||
type: 'object', | ||
properties: { | ||
event: { type: 'object' }, | ||
input: { type: 'string', maxLength: 8192 }, |
There was a problem hiding this comment.
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
type: 'object', | ||
properties: { | ||
inputPathsMap: { type: 'object' }, | ||
inputTemplates: { type: 'string', maxLength: 8192 }, |
There was a problem hiding this comment.
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'] }, | |
], | |
}, | |
], | |
}); | |
} |
additionalProperties: false, | ||
}, | ||
description: { type: 'string', maxLength: 512 }, | ||
name: { type: 'string', pattern: '[a-zA-Z0-9-_.]+', maxLength: 64 }, |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @thewizarodofoz it looks great! I have just one concern, please see my comment
{ required: ['input'] }, | ||
{ required: ['inputPath'] }, | ||
{ required: ['inputTransformer'] }, |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @thewizarodofoz !
Closes: #8026