@@ -10,6 +10,7 @@ module.exports = Class.extend({
1010 this . _serverless = serverless ;
1111 this . _provider = serverless ? serverless . getProvider ( 'aws' ) : null ;
1212 this . _opts = opts ;
13+ this . _custom = serverless . service ? serverless . service . custom : null ;
1314
1415 if ( ! this . _provider ) {
1516 throw new Error ( 'This plugin must be used with AWS' ) ;
@@ -90,10 +91,12 @@ module.exports = Class.extend({
9091 pathPattern = lambdaAtEdge . pathPattern ,
9192 outputName = this . _provider . naming . getLambdaVersionOutputLogicalId ( fnName ) ,
9293 distName = lambdaAtEdge . distribution ,
94+ fnObj = template . Resources [ fnLogicalName ] ,
9395 fnProps = template . Resources [ fnLogicalName ] . Properties ,
9496 evtType = lambdaAtEdge . eventType ,
9597 output = template . Outputs [ outputName ] ,
9698 dist = template . Resources [ distName ] ,
99+ retainFunctions = this . _custom && this . _custom . lambdaAtEdge && ( this . _custom . lambdaAtEdge . retain === true ) ,
97100 distConfig , cacheBehavior , fnAssociations , versionLogicalID ;
98101
99102 if ( ! _ . contains ( VALID_EVENT_TYPES , evtType ) ) {
@@ -130,6 +133,10 @@ module.exports = Class.extend({
130133 }
131134 }
132135
136+ if ( retainFunctions ) {
137+ fnObj . DeletionPolicy = 'Retain' ;
138+ }
139+
133140 distConfig = dist . Properties . DistributionConfig ;
134141
135142 if ( pathPattern ) {
0 commit comments