Hi team, is it best practice to create separate AP...
# help
j
Hi team, is it best practice to create separate API stacks for different APIs? For example, I have a
notes
REST API with associated verbs. I also have a
transactions
API with associated verbs. Should I create two separate modules/stacks - one for each API?
a
You can have multiple API Gateways in the same stack as well. Think of a stack as a group of infrastructure which has resources closely related to each other. You could build your entire application in a single API Gateway or you could use 10. My primary reason of using multiple gateways it to be able to avoid triggering per gateway limits and to be able to finely tune the authentication and authorisation levels per API / route.
j
so something like this:
Copy code
export default class ApiStack extends Stack {
  constructor(scope, id, props) {
    super(scope, id, props):
    api1 = new Api(this,"Api1", {...});
    api2 = new Api(this,"Api2", {...});
    api3 = new Api(this,"Api3", {...});
  }
}
a
yep, that’ll work.
j
This will create one AGW with the routes defined in each of the
new API
?
a
no, each API is another API Gateway instance.
j
So to keep 1 instance I would define all my routes in the same
new Api
?
a
yes, exactly.
j
Got it thanks Ashishkumar
a
of course.