[question] how to manage the api gateway paths without define them one by one in Routes.js
See original GitHub issueVery thanks to create this demo that I can easily start a Cognito UI in 5 minutes (the only change is to replace src/config.js with my cognito details)
But when go through src/Routes.js, I realised that I need define api gateway paths individually
In this demo, you made paths Notes
and Notes/{id}
with backend serverless API
create:
handler: create.main
events:
- http:
path: notes
method: post
cors: true
authorizer: aws_iam
get:
handler: get.main
events:
- http:
path: notes/{id}
method: get
cors: true
authorizer: aws_iam
But I have a lot of paths in api gateway events, do I have to write routes for each path? I don’t want to do that.
So how to manage the api gateway paths without define them one by one in src/Routes.js
? After cognito login, it should redirects the access to backend API gateway, let API gateway takes over the rest.
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Working with routes for HTTP APIs - Amazon API Gateway
Routes direct incoming API requests to backend resources. Routes consist of two parts: an HTTP method and a resource path—for example, GET /pets...
Read more >Routing API Gateway Traffic Through One Lamda Function
AWS only allows you to define one handler per Lambda function. While you can put multiple handlers into a single handler.js each of...
Read more >AWS Lambda + API Gateway routing best practice [closed]
Make a single catch-all lambda handler on $default route and use event.rawPath + event.requestContext.http.method to return different result ...
Read more >API gateway pattern - Microservice Architecture
Implement an API gateway that is the single entry point for all clients. The API gateway handles requests in one of two ways....
Read more >REST API (API Gateway v1) - Serverless Framework
You can define more than one path resource, but by default, Serverless will generate them from the root resource. restApiRootResourceId is optional if...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@ozbillwang Say for example you want
/notes
,/pages
,/chapters
, etc.; you can add those routes as/:object
and link to just one JS file.Role based access is a bit trickier but here is a good article on setting this up - https://aws.amazon.com/blogs/aws/new-amazon-cognito-groups-and-fine-grained-role-based-access-control-2/
With the above setup each user group can be assigned a different IAM role and that can restrict access to the necessary endpoints. In this chapter we create the roles - https://serverless-stack.com/chapters/create-a-cognito-identity-pool.html. So your role would not be
"arn:aws:execute-api:YOUR_API_GATEWAY_REGION:*:YOUR_API_GATEWAY_ID/*"
but"arn:aws:execute-api:YOUR_API_GATEWAY_REGION:*:YOUR_API_GATEWAY_ID/endpoint1*"
. Or something along those lines.thanks, @jayair
"arn:aws:execute-api:YOUR_API_GATEWAY_REGION::YOUR_API_GATEWAY_ID/<group1>"
makes sense for me ( I will use group name as endpoint name)