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 cloudfront event schema #8250
Aws cloudfront event schema #8250
Conversation
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.
Thanks you @thewizarodofoz ! It looks promising. Please see my comments
Is the regex for pathPattern necessary? I derived it from this doc
I think what you proposed looks good. I've just picked on few potential issues
Should I add the full schema for origin? It will be quite verobse
In general we define all config properties, and we did so for all events so far. So in this case I'd also ensure that we define them all.
There's a pretty good reference for it: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cloudfront-distribution-origin.html
Should I add the full schema for behavior? It will be quite verobse..
Yes I'd also follow with it. Here case is more complex as some properties are supported on its own in upper level (as pathPattern
). In this case I'd allow to set only properties which are not handled in other scope (so no support for PathPattern
at this level)
Will the uri format work for origin?
I think it's a great pick (btw I've just learned about format
keyword`)
isDefaultOrigin: { type: 'boolean' }, | ||
includeBody: { type: 'boolean' }, | ||
behavior: { type: 'object' }, | ||
}, |
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 add additionalProperties: false
type: 'string', | ||
enum: ['viewer-request', 'origin-request', 'origin-response', 'viewer-response'], | ||
}, | ||
pathPattern: { type: 'string', pattern: '^([A-Za-z0-9-_.*$/~"\'@:+]|&)+$' }, |
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.
-
char needs to be escaped (otherwise in []
it implies a range between characters.
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.
moved it to the end of the array like we do in other patterns
Codecov Report
@@ Coverage Diff @@
## master #8250 +/- ##
==========================================
- Coverage 88.11% 88.02% -0.09%
==========================================
Files 248 248
Lines 9388 9312 -76
==========================================
- Hits 8272 8197 -75
+ Misses 1116 1115 -1
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 that looks outstanding! I've found few last issues, otherwise it looks as what we need
HTTPPort: { type: 'integer' }, | ||
HTTPSPort: { type: 'integer' }, |
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 maybe set min 0
and max 65535
HTTPSPort: { type: 'integer' }, | ||
OriginKeepaliveTimeout: { type: 'integer', miminum: 1, maximum: 60 }, | ||
OriginProtocolPolicy: { | ||
type: 'string', |
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.
With enum
, type
is ineffective
OriginReadTimeout: { type: 'integer', miminum: 1, maximum: 60 }, | ||
OriginSSLProtocols: { | ||
type: 'array', | ||
items: { type: 'string', enum: ['SSLv3', 'TLSv1', 'TLSv1.1', 'TLSv1.2'] }, |
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.
Same here
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.
Doesn't seem to be addressed (we can remove type: 'string'
)
required: ['OriginProtocolPolicy'], | ||
}, | ||
DomainName: { type: 'string' }, | ||
Id: { type: 'string' }, |
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 not include Id
, as we unconditionally generate it:
Id: naming.getCloudFrontOriginId(originObj), |
{ type: 'array', items: [{ const: 'GET' }, { const: 'HEAD' }] }, | ||
{ type: 'array', items: [{ const: 'GET' }, { const: 'HEAD' }, { const: 'OPTIONS' }] }, | ||
{ | ||
type: 'array', | ||
items: [ | ||
{ const: 'GET' }, | ||
{ const: 'HEAD' }, | ||
{ const: 'OPTIONS' }, | ||
{ const: 'PUT' }, | ||
{ const: 'PATCH' }, | ||
{ const: 'POST' }, | ||
{ const: 'DELETE' }, | ||
], | ||
}, |
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.
If understand we allow three exact collections. If it's the case then above doesn't meet that, as AllowedMethods: ["GET"]
will pass.
I believe we can achieve needed validation through { enum: [["GET", "HEAD"], [... ], [...]] }
oneOf: [ | ||
{ type: 'array', items: [{ const: 'GET' }, { const: 'HEAD' }] }, | ||
{ type: 'array', items: [{ const: 'GET' }, { const: 'HEAD' }, { const: '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.
Same here
SmoothStreaming: { type: 'boolean' }, | ||
TrustedSigners: { type: 'array', items: { type: 'string' } }, | ||
ViewerProtocolPolicy: { | ||
type: 'string', |
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.
No need for type
}, | ||
isDefaultOrigin: { type: 'boolean' }, | ||
includeBody: { type: 'boolean' }, | ||
behavior: behaviorObjectSchema, |
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 ensure alphabetical order (when there's larger count of properties, it's then easier to find one)
this.serverless.configSchemaHandler.defineFunctionEvent('aws', 'cloudFront', { | ||
type: 'object', | ||
properties: { | ||
eventType: { | ||
type: 'string', |
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 remove type
here
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.
@thewizarodofoz that looks great! There's just one style nit that left addressed, see my comment
OriginReadTimeout: { type: 'integer', miminum: 1, maximum: 60 }, | ||
OriginSSLProtocols: { | ||
type: 'array', | ||
items: { type: 'string', enum: ['SSLv3', 'TLSv1', 'TLSv1.1', 'TLSv1.2'] }, |
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.
Doesn't seem to be addressed (we can remove type: 'string'
)
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! That's outstanding!
Closes: #8025
A few things I'm not sure of: