File tree 2 files changed +18
-13
lines changed
lib/deploy/events/apiGateway 2 files changed +18
-13
lines changed Original file line number Diff line number Diff line change @@ -43,10 +43,13 @@ module.exports = {
43
43
} ,
44
44
} ) ;
45
45
46
- if ( ! _ . isEmpty ( this . serverless . service . provider . resourcePolicy ) ) {
46
+ const resourcePolicy = _ . get ( this . serverless . service . provider . apiGateway , 'resourcePolicy' )
47
+ || this . serverless . service . provider . resourcePolicy ;
48
+
49
+ if ( ! _ . isEmpty ( resourcePolicy ) ) {
47
50
const policy = {
48
51
Version : '2012-10-17' ,
49
- Statement : this . serverless . service . provider . resourcePolicy ,
52
+ Statement : resourcePolicy ,
50
53
} ;
51
54
_ . merge ( this . serverless . service . provider . compiledCloudFormationTemplate
52
55
. Resources [ this . apiGatewayRestApiLogicalId ] . Properties , {
Original file line number Diff line number Diff line change @@ -89,19 +89,21 @@ describe('#compileRestApi()', () => {
89
89
} ) ) ;
90
90
91
91
it ( 'should create a REST API resource with resource policy' , ( ) => {
92
- serverlessStepFunctions . serverless . service . provider . resourcePolicy = [
93
- {
94
- Effect : 'Allow' ,
95
- Principal : '*' ,
96
- Action : 'execute-api:Invoke' ,
97
- Resource : [ 'execute-api:/*/*/*' ] ,
98
- Condition : {
99
- IpAddress : {
100
- 'aws:SourceIp' : [ '123.123.123.123' ] ,
92
+ serverlessStepFunctions . serverless . service . provider . apiGateway = {
93
+ resourcePolicy : [
94
+ {
95
+ Effect : 'Allow' ,
96
+ Principal : '*' ,
97
+ Action : 'execute-api:Invoke' ,
98
+ Resource : [ 'execute-api:/*/*/*' ] ,
99
+ Condition : {
100
+ IpAddress : {
101
+ 'aws:SourceIp' : [ '123.123.123.123' ] ,
102
+ } ,
101
103
} ,
102
104
} ,
103
- } ,
104
- ] ;
105
+ ] ,
106
+ } ;
105
107
return serverlessStepFunctions . compileRestApi ( ) . then ( ( ) => {
106
108
expect ( serverlessStepFunctions . serverless . service . provider
107
109
. compiledCloudFormationTemplate . Resources ) . to . deep . equal (
You can’t perform that action at this time.
0 commit comments