File tree Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -32,3 +32,13 @@ Run deploy
32
32
` ` `
33
33
$ serverless deploy
34
34
```
35
+
36
+ You can specify additional configurations a ` lambdaEdgePreExistingCloudFront ` value in the custom section of your serverless.yml file.
37
+ A ` validStages ` value allows you to specify valid stage names for deploy Lambda@Edge.
38
+
39
+ ``` yaml
40
+ lambdaEdgePreExistingCloudFront :
41
+ validStages :
42
+ - staging
43
+ - production
44
+ ` ` `
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ class ServerlessLambdaEdgePreExistingCloudFront {
15
15
const functionObj = this . serverless . service . getFunction ( functionName )
16
16
if ( functionObj . events ) {
17
17
functionObj . events . forEach ( async ( event ) => {
18
- if ( event . preExistingCloudFront ) {
18
+ if ( event . preExistingCloudFront && this . checkAllowedDeployStage ( ) ) {
19
19
const functionArn = await this . getlatestVersionLambdaArn ( functionObj . name )
20
20
const config = await this . provider . request ( 'CloudFront' , 'getDistribution' , {
21
21
Id : event . preExistingCloudFront . distributionId
@@ -53,6 +53,23 @@ class ServerlessLambdaEdgePreExistingCloudFront {
53
53
}
54
54
}
55
55
56
+ checkAllowedDeployStage ( ) {
57
+ if (
58
+ this . serverless . service . custom &&
59
+ this . serverless . service . custom . lambdaEdgePreExistingCloudFront &&
60
+ this . serverless . service . custom . lambdaEdgePreExistingCloudFront . validStages
61
+ ) {
62
+ if (
63
+ this . serverless . service . custom . lambdaEdgePreExistingCloudFront . validStages . indexOf (
64
+ this . stage
65
+ ) < 0
66
+ ) {
67
+ return false
68
+ }
69
+ }
70
+ return true
71
+ }
72
+
56
73
async associateNonDefaultCacheBehaviors ( cacheBehaviors , event , functionName , functionArn ) {
57
74
for ( let i = 0 ; i < cacheBehaviors . Items . length ; i ++ ) {
58
75
if ( event . preExistingCloudFront . pathPattern === cacheBehaviors . Items [ i ] . PathPattern ) {
You can’t perform that action at this time.
0 commit comments