I found this link that talks about separating static data and a web api into a static s3 web server and a bean stalk application for an api and an ec2 web server to create a website. The answer from Charles is accurate, CORS is how you address the problem with moving between the two domains.
How to use S3 as static web page and EC2 as REST API for it together? (AWS)
The question I have is why you would do this?
Some of my thoughts are:
Advantage - We use node as the web server for the api and this would lighten the burden on the node process.
That's about it.
Disadvantages of not simply using Bean Stalk to do it all
Added complexity of CORS Updating the software is more complex Seems like overkill unless you have a serious amount of static data which I do not
Am I missing another advantage
There are a lot of advantages to separating your front-end logic out from your back-end logic, and deploying them separately.
The first big reason is that doing things this way allows you to separate your business logic (your API) from your design (your front-end).
You can keep both projects in separate Git repos. You can have your designers ship as many updates to the front-end project as they want, without ever needing to bother an engineer.
Doing that in a single monolithic project (on Elastic Beanstalk, for instance): would be nearly impossible, as designers would need to iterate their code through the engineering team.
Web servers are slow. File servers (like S3) are fast. The reason they are fast is that there is no 'code' running to access files from a file server -- there is just a file being downloaded.
If you have a single monolithic web application served from an EC2 instance, for example, this means that to view a page, you need to run some code to generate that HTML.
If you deploy your front-end code to S3, however, that file can be directly downloaded by the web browser MUCH faster.
PROTIP: You can also put your S3 website behind CloudFront (a CDN) to speed up your website EVEN MORE by keeping a cached copy if it in multiple data centers around the world.
When you have your projects separated, and deployed separately, you can iterate faster.
Let's say your front-end team finds a bug in the website. They can easily patch / release a fix WITHOUT going through engineering.
The same is true of your engineers -- they now have more time to focus on building the core application logic, and can deploy fixes without worrying about UI changes, etc.
When you deploy things separately as you've described, you also get the benefit of simplifying your back-end logic.
By having your core engineers just build APIs, and stop worrying about front-end concerns, you can ship updates significantly quicker than you could otherwise.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With