-
Notifications
You must be signed in to change notification settings - Fork 5.7k
feat(aws): schema for resources when using AWS provider
#8139
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -220,6 +220,15 @@ class AwsProvider { | |||
| required: ['Fn::Sub'], | ||||
| additionalProperties: false, | ||||
| }, | ||||
| awsResourceProperties: { | ||||
| Properties: { type: 'object' }, | ||||
| CreationPolicy: { type: 'object' }, | ||||
| DeletionPolicy: { type: 'string' }, | ||||
| DependsOn: { type: 'array', items: { type: 'string' } }, | ||||
| Metadata: { type: 'object' }, | ||||
| UpdatePolicy: { type: 'object' }, | ||||
| UpdateReplacePolicy: { type: 'string' }, | ||||
| }, | ||||
| }, | ||||
| provider: { | ||||
| properties: { | ||||
|
|
@@ -323,8 +332,76 @@ class AwsProvider { | |||
| }, | ||||
| }, | ||||
| }, | ||||
| // TODO: Complete schema, see https://github.com/serverless/serverless/issues/8014 | ||||
| resources: { type: 'object' }, | ||||
| resources: { | ||||
| properties: { | ||||
| AWSTemplateFormatVersion: { | ||||
| type: 'string', | ||||
| }, | ||||
| Description: { | ||||
| type: 'string', | ||||
| }, | ||||
| Metadata: { | ||||
| type: 'object', | ||||
| }, | ||||
| Parameters: { | ||||
| type: 'object', | ||||
| }, | ||||
| Mappings: { | ||||
| type: 'object', | ||||
| }, | ||||
| Conditions: { | ||||
| type: 'object', | ||||
| }, | ||||
| Transform: { | ||||
| type: 'object', | ||||
| }, | ||||
| // Not replicating the full JSON schema from https://s3.amazonaws.com/cfn-resource-specifications-us-east-1-prod/schemas/2.15.0/all-spec.json | ||||
| // as that gets into the specifics for each resource type. | ||||
| // | ||||
| // The only required attribute is `Type`; `Properties` and other common attributes are optional. | ||||
| // See also https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/resources-section-structure.html | ||||
| Resources: { | ||||
| type: 'object', | ||||
| patternProperties: { | ||||
| '^[a-zA-Z0-9]{1,255}$': { | ||||
| type: 'object', | ||||
| properties: { | ||||
| $ref: '#/definitions/awsResourceProperties', | ||||
| }, | ||||
| additionalProperties: { | ||||
| Type: { type: 'string' }, | ||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It'll probably be good to add definition for Ideally if we define all those properties (aside of So they're added to this object: serverless/lib/configSchema.js Line 116 in 5f85543
With this move I would also define Having that I would reuse this definition here, in form: {
properties: { $ref: '#/definitions/awsResource' },
additionalProperties: {
Type: { type: "string: }
}and reuse it also in context of
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've put in a first attempt at a smoke-check definition for Note that the supported properties for I can look into adding support for extending
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Both
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @medikoo
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, afaik the only difference between them is that That's also the reason why I suggested to exclude |
||||
| }, | ||||
| }, | ||||
| }, | ||||
| additionalProperties: false, | ||||
| }, | ||||
| extensions: { | ||||
| type: 'object', | ||||
| patternProperties: { | ||||
| // names have the same restrictions as CloudFormation Resources section | ||||
| '^[a-zA-Z0-9]{1,255}$': { | ||||
| type: 'object', | ||||
| // this lists the supported properties, other properties are "Not supported. An error will be thrown | ||||
| // if you try to extend an unsupported attribute." | ||||
| // this is different than the above schema for `Resources`, which allows the `Type` attribute. | ||||
| // extensions are explicitly meant to extend the definition of existing resources. | ||||
| properties: { | ||||
| $ref: '#/definitions/awsResourceProperties', | ||||
| }, | ||||
| additionalProperties: false, | ||||
| }, | ||||
| }, | ||||
| additionalProperties: false, | ||||
| }, | ||||
| // According to https://s3.amazonaws.com/cfn-resource-specifications-us-east-1-prod/schemas/2.15.0/all-spec.json | ||||
| // `Outputs` is just an "object", though it seems like this is under-specifying that section a bit. | ||||
| // See also https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/outputs-section-structure.html | ||||
| Outputs: { | ||||
| type: 'object', | ||||
| }, | ||||
| }, | ||||
| additionalProperties: false, | ||||
| }, | ||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need |
||||
| }); | ||||
| } | ||||
| this.requestCache = {}; | ||||
|
|
||||
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 provide definitions for all possible CF template properties (listed here: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-anatomy.html ) but ofc without going into deep details, it should serve more as sanity check
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.
To clarify: you're just looking for a top-level check on
AWSTemplateFormatVersion,Description,Metadata,Parameters,Mappings,Conditions,Transform, andOutputsin addition to the existing schema forResourceshere?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.
Yes, exactly, as all of them are supported by Framework