@@ -10,6 +10,7 @@ module.exports = Class.extend({
10
10
this . _serverless = serverless ;
11
11
this . _provider = serverless ? serverless . getProvider ( 'aws' ) : null ;
12
12
this . _opts = opts ;
13
+ this . _custom = serverless . service ? serverless . service . custom : null ;
13
14
14
15
if ( ! this . _provider ) {
15
16
throw new Error ( 'This plugin must be used with AWS' ) ;
@@ -90,10 +91,12 @@ module.exports = Class.extend({
90
91
pathPattern = lambdaAtEdge . pathPattern ,
91
92
outputName = this . _provider . naming . getLambdaVersionOutputLogicalId ( fnName ) ,
92
93
distName = lambdaAtEdge . distribution ,
94
+ fnObj = template . Resources [ fnLogicalName ] ,
93
95
fnProps = template . Resources [ fnLogicalName ] . Properties ,
94
96
evtType = lambdaAtEdge . eventType ,
95
97
output = template . Outputs [ outputName ] ,
96
98
dist = template . Resources [ distName ] ,
99
+ retainFunctions = this . _custom && this . _custom . lambdaAtEdge && ( this . _custom . lambdaAtEdge . retain === true ) ,
97
100
distConfig , cacheBehavior , fnAssociations , versionLogicalID ;
98
101
99
102
if ( ! _ . contains ( VALID_EVENT_TYPES , evtType ) ) {
@@ -130,6 +133,10 @@ module.exports = Class.extend({
130
133
}
131
134
}
132
135
136
+ if ( retainFunctions ) {
137
+ fnObj . DeletionPolicy = 'Retain' ;
138
+ }
139
+
133
140
distConfig = dist . Properties . DistributionConfig ;
134
141
135
142
if ( pathPattern ) {
0 commit comments