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

Conversation

thewizarodofoz
Copy link
Contributor

Closes: #8026

@codecov-commenter
Copy link

codecov-commenter commented Sep 14, 2020

Codecov Report

Merging #8230 into master will decrease coverage by 0.06%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            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              
Impacted Files Coverage Δ
...ws/package/compile/events/cloudWatchEvent/index.js 100.00% <100.00%> (ø)
...plugins/aws/package/compile/events/stream/index.js 98.00% <0.00%> (-0.60%) ⬇️
lib/utils/getServerlessConfigFile.js 94.11% <0.00%> (ø)
lib/plugins/aws/provider/awsProvider.js 93.11% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4af57a5...5b1f3ad. Read the comment docs.

Copy link
Contributor

@medikoo medikoo left a 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 },
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

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'] },
],
},
],
});
}

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

@thewizarodofoz thewizarodofoz changed the title aws cloudwatch event schema aws cloudwatchEvent event schema Sep 15, 2020
Copy link
Contributor

@medikoo medikoo left a 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

Comment on lines +39 to +41
{ required: ['input'] },
{ required: ['inputPath'] },
{ required: ['inputTransformer'] },
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

Copy link
Contributor

@medikoo medikoo left a comment

Choose a reason for hiding this comment

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

Thank you @thewizarodofoz !

@medikoo medikoo merged commit 3730fd4 into serverless:master Sep 15, 2020
@thewizarodofoz thewizarodofoz deleted the aws-cloudwatchevent-event-schema branch September 15, 2020 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Config schema: Define AWS "cloudwatchEvent" function event properties
3 participants