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

layers schema #8299

Merged
merged 11 commits into from Oct 1, 2020
11 changes: 11 additions & 0 deletions docs/providers/aws/guide/plugins.md
Expand Up @@ -562,6 +562,17 @@ class NewProviderPlugin {
// ...
},
},

// Definition for eventual top level "layers" section
layers: {
type: 'object',
additionalProperties: {
type: 'object',
properties: {
// ...
},
},
},
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/classes/ConfigSchemaHandler/index.js
Expand Up @@ -54,7 +54,6 @@ class ConfigSchemaHandler {
Object.freeze(this.schema.properties.service.name);
deepFreeze(this.schema.properties.plugins);
deepFreeze(this.schema.properties.package);
Object.freeze(this.schema.properties.layers);
}

validateConfig(userConfig) {
Expand Down Expand Up @@ -174,6 +173,7 @@ class ConfigSchemaHandler {
}

if (options.resources) this.schema.properties.resources = options.resources;
if (options.layers) this.schema.properties.layers = options.layers;

// In case provider implementers do not set stage or variableSyntax options,
// then they are set here. The framework internally sets these options in
Expand Down
3 changes: 0 additions & 3 deletions lib/configSchema.js
Expand Up @@ -109,9 +109,6 @@ const schema = {
additionalProperties: false,
},

// TODO: Complete schema, see https://github.com/serverless/serverless/issues/8015
layers: { type: 'object' },

/*
* Modes for config validation:
* - error: the error is thrown
Expand Down
47 changes: 47 additions & 0 deletions lib/plugins/aws/provider/awsProvider.js
Expand Up @@ -504,6 +504,53 @@ class AwsProvider {
},
additionalProperties: false,
},
layers: {
type: 'object',
additionalProperties: {
type: 'object',
properties: {
allowedAccounts: {
type: 'array',
items: {
oneOf: [
{ type: 'integer', minimum: 100000000000, maximum: 999999999999 },
Copy link
Contributor

Choose a reason for hiding this comment

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

Today I've turned on automatic coercion with #8319, and having that I believe we no longer need that number definition.

We can also remove the logic which tries to handle eventual numeric input

{
type: 'string',
pattern: '^(\\d{12}|\\*|arn:(aws[a-zA-Z-]*):iam::\\d{12}:root)$',
},
],
},
},
compatibleRuntimes: {
type: 'array',
items: { $ref: '#/definitions/awsLambdaRuntime' },
maxItems: 5,
},
description: { type: 'string', maxLength: 256 },
licenseInfo: { type: 'string', maxLength: 512 },
name: {
type: 'string',
minLength: 1,
maxLength: 140,
pattern:
'^((arn:[a-zA-Z0-9-]+:lambda:[a-zA-Z0-9-]+:\\d{12}:layer:[a-zA-Z0-9-_]+)|[a-zA-Z0-9-_]+)$',
},
package: {
type: 'object',
properties: {
artifact: { type: 'string' },
exclude: { type: 'array', items: { type: 'string' } },
include: { type: 'array', items: { type: 'string' } },
},
additionalProperties: false,
},
path: { type: 'string' },
retain: { type: 'boolean' },
},
required: ['path'],
additionalProperties: false,
},
},
resources: {
properties: {
AWSTemplateFormatVersion: {
Expand Down