File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -169,6 +169,40 @@ stepFunctions:
169169 definition:
170170` ` `
171171
172+ # ### [Share API Gateway and API Resources](https://serverless.com/framework/docs/providers/aws/events/apigateway/#share-api-gateway-and-api-resources)
173+
174+ You can share the same API Gateway between multiple projects by referencing its REST API ID and Root Resource ID in serverless.yml as follows :
175+
176+ ` ` ` yml
177+ service: service-name
178+ provider:
179+ name: aws
180+ apiGateway:
181+ restApiId: xxxxxxxxxx # REST API resource ID. Default is generated by the framework
182+ restApiRootResourceId: xxxxxxxxxx # Root resource, represent as / path
183+
184+ functions:
185+ ...
186+ ` ` `
187+ If your application has many nested paths, you might also want to break them out into smaller services.
188+
189+ However, Cloudformation will throw an error if we try to generate an existing path resource. To avoid that, we reference the resource ID :
190+
191+ ` ` ` yml
192+ service: service-a
193+ provider:
194+ apiGateway:
195+ restApiId: xxxxxxxxxx
196+ restApiRootResourceId: xxxxxxxxxx
197+ restApiResources: # List of existing resources that were created in the REST API. This is required or the stack will be conflicted
198+
199+ /posts: xxxxxxxxxx
200+
201+ functions:
202+ ...
203+ ` ` `
204+
205+
172206# ### Enabling CORS
173207
174208To set CORS configurations for your HTTP endpoints, simply modify your event configurations as follows :
You can’t perform that action at this time.
0 commit comments