admin管理员组文章数量:1309963
I’m new to Replit and couldn’t find a clear answer in the documentation. I would like to build a web-based application on Replit that uses AWS DynamoDB as the primary data store.
My main questions are:
Is it possible to connect a Replit-hosted web application to DynamoDB?
What is the best approach? Should I:
Connect directly using the AWS SDK (e.g., aws-sdk for JavaScript/Node.js)?
Build a separate API layer (e.g., an AWS Lambda function with API Gateway) and have the Replit app interact with it?
If both are viable, what are the pros and cons of each approach in a Replit environment?
I appreciate any insights, and thanks in advance for your help!
Many thanks, Nick
I’m new to Replit and couldn’t find a clear answer in the documentation. I would like to build a web-based application on Replit that uses AWS DynamoDB as the primary data store.
My main questions are:
Is it possible to connect a Replit-hosted web application to DynamoDB?
What is the best approach? Should I:
Connect directly using the AWS SDK (e.g., aws-sdk for JavaScript/Node.js)?
Build a separate API layer (e.g., an AWS Lambda function with API Gateway) and have the Replit app interact with it?
If both are viable, what are the pros and cons of each approach in a Replit environment?
I appreciate any insights, and thanks in advance for your help!
Many thanks, Nick
Share Improve this question asked Feb 1 at 23:34 Nk MkNk Mk 1,0892 gold badges11 silver badges21 bronze badges 3- Replit user here, I would try using the SDK. Note if any of them use localhost to connect, you may have a bit of trouble. – NateDhaliwal Commented Feb 2 at 6:25
- Hello, thanks for your reply. Which SDK are you referring to? AWS SDK?....is this something you've tried before? Thanks – Nk Mk Commented Feb 21 at 13:13
- Yes, sorry. You can take a look here. – NateDhaliwal Commented Feb 22 at 7:00
2 Answers
Reset to default 1It's a better idea to use API Gateway and Lambda than to build the API directly in your web application, for many reasons. It means you don't have to handle access keys in your web app, which is more secure, but it also provides more flexibility, should you need to alter your API's in the future. You can create versions of you Lambda, and incorporate smart routing logic.
Directly accessing the data-storage layer from the frontend is almost never a good idea because of 2 reasons
Security: Your client app needs direct access to the database. And depending on the usecase, restricting the privileges for accessing the database may be very hard to impossible. Ie someone extracting accesskeys/tokens from your app (which is especially easy with webapps) may gain full access to your database.
But when you have an API Layer in between, the client app doesn't need any privileges on the database and can only access the data, that you explicitely make accessible through the API.
Maintainability: An intermediate API layer is an additional level of abstraction. Ie it makes it much easier to refactor your app, add/remove functionality, or even move to a totally different datastorage.
So you will need some API/Backend layer for your fontend to communicate with. That can be either AWS API Gateway or any other server/service hosting a backend app providing API endpoints
I only know Replit by name and never worked with it, so I don't know if the provide the possibility of a backend. If that's the case, you can of course implement the API Layer on that backend and connect to your datastorage from that backend (with the AWS SDK for DynamoDB). There would be no need for an additional AWS API Gateway layer ...
But on the other hand, if you are planning to host your data on AWS anyway, you probably don't need any additional service provider at all. You can store your data in DynamoDB, provide your API Endpoints via API Gateway, serve your frontend via S3 and CloudFront and handle authentication via Cognito. This concept is known as "serverless computing" (not to confuse with the serverless framework which provides a relatively simple toolset to create such apps with different providers like AWS, Microsoft or Google, but there are other similar frameworks too)
本文标签:
版权声明:本文标题:node.js - Can I connect a Replit web application to AWS DynamoDB, and should I use APIs or the AWS SDK? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741860333a2401586.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论