diff --git a/src/index.js b/src/index.js index ddaf8a2..7dcf0ad 100644 --- a/src/index.js +++ b/src/index.js @@ -16,6 +16,43 @@ module.exports = Class.extend({ throw new Error('This plugin must be used with AWS'); } + serverless.configSchemaHandler.defineCustomProperties({ + type: 'object', + properties: { + 'lambdaAtEdge': { + type: 'object', + properties: { + retain: { type: 'boolean' }, + }, + }, + }, + }); + + const functionPropertySchema = { + type: 'object', + properties: { + distribution: { type: 'string' }, + eventType: { enum: VALID_EVENT_TYPES }, + pathPattern: { type: 'string' }, + }, + required: [ 'distribution', 'eventType' ], + }; + + serverless.configSchemaHandler.defineFunctionProperties('aws', { + properties: { + 'lambdaAtEdge': { + oneOf: [ + { + type: 'array', + items: functionPropertySchema, + }, + functionPropertySchema, + ], + }, + }, + required: [ 'lambdaAtEdge' ], + }); + this.hooks = { 'aws:package:finalize:mergeCustomProviderResources': this._modifyTemplate.bind(this), }; diff --git a/src/tests/index.test.js b/src/tests/index.test.js index d6d87bf..750acc6 100644 --- a/src/tests/index.test.js +++ b/src/tests/index.test.js @@ -15,6 +15,10 @@ function stubServerless() { consoleLog: _.noop, printDot: _.noop, }, + configSchemaHandler: { + defineCustomProperties: _.noop, + defineFunctionProperties: _.noop, + }, }; }