简体   繁体   中英

AWS serverless and API resource

I have a webapp bundled that I plan on serving from s3. My webapp consumes data from a web-service API (Java) running in AWS.

I would like to have separate environments, "DEV", "TEST", "PROD", thus I would like to have https://dev.mysite.com , https://test.mysite.com , etc.

I would like to be able to serve both the static files from s3 as well as consume the web-service resources from the same hostname, ie: https://dev.mysite.com/index.html and then the web-service API https://dev.mysite.com/api/users

What is the best solution to accomplish this? The reason for this is that my web-service environments use different databases depending on env.

My initial thoughts are to create a route53 for each ENV and inside the JAVA web-service server check each request and if it doesn't start w/ "/api" then assume it's a request for a file and serve that file else handle the api request.

You can setup a AWS CloudFront distribution which can be configured to route to your API backend or S3 to serve static content based on URL patterns.

In addition it will also improve your application performance by caching s3 content in CDN and serving through closest edge location.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM