micro service web app with AWS - amazon-web-services

I am developing a web application for image upload and retrieval with AWS cloud services using a micro service architecture.
I am new to AWS and micro service architecture, please help me map the components of the architecture to AWS components.
Do i consider each micro service to run on one EC2 instance with auto scaling and load balancing?
Or do I run each micro service on one EC2 cluster?
If i put my static html files in an S3, how can i call database methods to load the html pages with content?
Is it by calling am API gateway from the client?
I have searched the web, but was unable to find a tutorial which implements multiple services as micro services using AWS EC2 / ECS.
Please help me figure out how to map my requirements and if there are any tutorials on implementing a similar app, will be very helpful.
Thank you in advance! :)

In short, you could use the serverless architecture i.e (with AWS's APIGateway and Lambda services) to build robust micro service based web applications.
Since you said that you were new to micro services architecture, I am listing down the best approaches.
Frontend/client
Single page applications(SPA) work well in the front-end and as they are a static site, they could be easily deployed to S3. This is the most cost efficient approach for SPAs. Here is a video deploying SPA on S3. This video will guide you through step by step instructions for deploying your SPA.
In case, you use react and redux in the front end, check out these steps for deploying react app to S3.
Backend
AWS EC2 is a good option. But there are many more alternatives available. As you said, you were new to backend, setting up EC2, VPC's and Elastic-ip is a little difficult process.
Nowadays, SPA's cover a lot of business logic, routing, etc., We need our backend only as API's for performing CRUD operations with database. I would like to suggest a bleeding edge technology called serverless. Here is the tutorial for launching your backend within 5 minutes. AWS lambda is a service that is called as function as service. You can build your backend using AWS lambda + API gateway + DynamoDB.
For eg: say you want to register some details in backend, you will POST all the data from client to your backend with url and proper path. In AWS lambda, you write your logic for POST as a function, which contains the logic to parse the data from request and send to dynamoDB. Now, this function can be exposed to world by connecting this function with API gateway( an another service in AWS). At the end we get an API, which can be used in your angular 2 APP. SO, on invoking the POST, angular 2 -> API gateway -> Lambda(extract request and send to DB) -> dynamoDB.
Benefits of using serverless compared to EC2.
You don't need to manage your server(EC2) from updating the new security patch to auto-scaling, everything is taken care by lambda. Serverless is a fully managed service.
You only pay when your lambda functions are invoked. On the contrast, even though your web app doesn't receive traffic for a given day, you have to pay the day-tariff for the given day.
Here is my github repo which could be a boiler plate for reactJS + Serverless + graphQL web app.
Having said, try serverless when compared to traditional backend approach. Any questions on this would be welcomed.

Related

How to build/deploy a Node AWS RDS backend for React S3 app

I am trying to set up an app on AWS that ...
Deploys a react app to an S3 bucket
Deploys a node backend that interacts with an AWS RDS database
Connects the react app front end to the node backend to do CRUD operations
Doing part 1 is easy and there are plenty of tutorials. However, parts 2 and 3 seem totally foreign to me. I have found nothing that explains how to tie the front end to the database or how to tie the front end to the back end.
Do I need an API Gateway?
Does the node backend have to be hosted on an EC2 instance?
If so, how do I do this?
Where does cloudformation come into play?
I have found nothing that explains how to tie the front end to the
database or how to tie the front end to the back end.
Frontend connects to the backend by making HTTP API calls (via fetch or a library like axios) to the URL associated with the backend server.
The backend would connect to the database via NodeJS database connections.
The frontend should never connect directly to the database.
Do I need an API Gateway?
Using API Gateway is entirely optional.
Does the node backend have to be hosted on an EC2 instance?
The Node backend needs to be deployed on a compute service that can run NodeJS code, such as AWS EC2, ECS, EKS, Lambda...
If so, how do I do this?
This part of your question is so broad it is off-topic for this site. Given your level of experience I suggest looking at AWS Elastic Beanstalk for deploying your backend.
Where does cloudformation come into play?
CloudFormation is a tool you use to define your AWS infrastructure as code, so instead of clicking around in the AWS UI to create everything, and then not being able to reproduce that reliably when you need to, everything is defined in template files that can be tracked in source control.
Where it "comes into play" is if you decide you want to use an Infrastructure as Code tool, you might use CloudFormation. It is entirely optional.

AWS choices for single microservice (spring boot) for Angular 7 client

I'm relatively new to AWS and wanted suggestions about the best options for my needs. I have a single spring boot API that is to be accessible only to my angular 7 client. The client will go in an S3 bucket. I need suggestions for how to host the API (it needs a MySQL autogenerated db).
So far I have seen ECS vs Elastic Beanstalk vs. Amplify. Can someone experienced suggest me an option that won't be overkill for this small project? The API could be called frequently depending on traffic to the client.
If you have suggestions from Azure or Google Cloud Platform those would be welcome too.
Thank you!
AWS provides the EC2 service where you can create an instance (virtual machine) and install/deploy manually your application and all the required software. For personal or very small projects this can be an option, but you should consider that your backend will not be able to scale to more instances automatically (or by configuration), you will have to take care of the configuration and backups of your database, etc.
For production-grade applications there are a lot of advantages of separating your application components, using a specific service for each component.
Given your application stack, I would recommend considering this approach:
Create a relational DB with AWS RDS
Deploy your Spring backend to AWS Beanstalk
Deploy your Angular frontend to AWS S3 (it can be served as static content)
Create a CloudFront distribution with two origins, to route the requests that must be delivered to backend (usually using a URL convention like /api/) and frontend ()

AWS API Gateway with EC2

I have a Django Project deployed in AWS EC2 and have created all the REST APIs with DRF. Everything is working great. When I point public.ip.of.ec2:8000/myapi, I get the correct response and these APIs are used in Android application.
Now, day by day the API hits will be increased. So in order to maintain API requests I want to integrate my APIs with APIGateway. After a lot of reading and searching I still could not find any definitive tutorial or steps as of how to integrate APIGateway with EC2.
I've followed this but still could not integrate APIGateway with AWS Service i.e., EC2.
Please suggest a way to do this.
I have a Django Project deployed in AWS EC2 and have created all the
REST APIs with DRF. Everything is working great. When I point
public.ip.of.ec2:8000/myapi, I get the correct response
Integration type you are looking for is HTTP integration
Now, day by day the API hits will be increased. So in order to
maintain API requests I want to integrate my APIs with APIGateway
Although you can configure API caching, throttling, logging and monitoring, AWS API Gateway won't scale your backend integration. You will need to configure autoscaling on backend service as well.

What parts of the AWS should I use for a web portal?

I am currently working on a web portal for a foundation. Applicants for a grant will receive access data in advance independently of this portal. New applications will then be created and processed in the portal itself. Once an application is complete, it is sent off. Later the application will be approved or rejected.
There are a number of technical specifications on which I have no influence. The frontend should be implemented using Html+Javascript. The backend should use the Amazon Web Services (AWS). If there is a need to program something for the backend - then C# should be used.
I know how to implement the classic client-server solution. At the moment, however, AWS offers me an unmanageable set of services. And here I'm hoping for suggestions as to which of the services I should take a closer look at. Ideally, no complete 'server solution' should run on a virtual server. Instead, Lambda functions are mentioned again and again. So would Amazon RDS and AWS Lambda be a sensible and sufficient combination? Did I miss something?
Thank you very much for your suggestions.
One solution would be to use AWS S3 to server HTML, CSS, JS, Images and other static content. You could use AWS Lambda via AWS API Gateway to serve as a backend. AWS Lambda would then connect to AWS RDS or AWS DynamoDB if you would prefer a NoSQL solution.
Image taken from AWS Github repo
You can get a more detailed description of how to set this up at
https://github.com/aws-samples/aws-serverless-workshops/tree/master/WebApplication/

Building an API on Google Cloud Platform

I'm building an app and the idea is to go serverless.
I'm looking mainly at AWS and GCP (Google Cloud Platform), and as AWS costs are a bit obscure (at least for me), and there is no way to ensure not being billed, I'm going with GCP.
For the "server" part of the app, I would like to build an API on GCP as I could do with AWS API Gateway, but I couldn't find any matching product for that.
The closer one was Google Cloud Endpoint, but it seems to have a very different concept from AWS API Gateway. I've watched some videos about it (for example https://www.youtube.com/watch?v=bR9hEyZ9774), but still can't get the idea behind it or if it fits my needs.
Could someone please help clarify which GCP product would be suitable for creating an API and how it compares to AWS API Gateway?
Some link with info/example on how to do it would be really appreciated.
Google Product Manager here.
We don't have an exact analog for AWS API Gateway.
You're right about Cloud Endpoints. It's a bit of a different architecture than AWS uses -- it's a sidecar proxy that gets deployed with the backend. That's different than API Gateway, which is a fully managed proxy deployed in front of your backends.
If you are deploying in App Engine Flexible environments: good news! The Endpoints Proxy can be deployed as part of your deployment. It can do things similar to AWS API Gateway (API key validation, JWT validation, rate limiting).
We are working on some plans to allow for the proxy to be used in other places (Cloud Functions and the newer App Engine Standard runtimes).
And, finally: on our older App Engine Java and Python runtimes, we have API Frameworks that provide the same functionality. Those frameworks do the same thing as the proxy, but get expressed as code annotations and built into your app. We're moving away from the framework model in favor of the proxy model.
An example of springboot project with google cloud app engine can be found here-https://github.com/ashishkeshu/googlecloud-springboot