REST API AWS cloud using java - java

I am new to AWS , want to develop a cloud ready java application REST API.
The application will hit the MySQL database and produce output as JSON after querying the database.
IP:port/application?q=<query> response is JSON.
How to achieve it ? the data in MySQL is mostly static 100MB data but used very frequently.

It is very straight forward. if you already have same application running in your local system , then you can just move it to AWS , using below steps :-
spin up new ec2 instance, if you are using a free-tier then you can spin up lots of AWS resources for free , more information on https://aws.amazon.com/free/ .
install all the required s/w like Java, maven , tomcat and mysql and whatever your application is using on Ec2 instance . you can even have a free RDS (Database) instance in free tier which you can use for your application , instead of having the database installed locally on your application server.
while creating the ec2 server , configure instance security group properly for ex 8080 for http and 22 for SSH , 3306 for mysql etc. (This is important and try to be as restrtict as possible to make it safe from hackers).
build and deploy your application and access it using any REST client , by giving instance ip and application port number.
There are several resources online for AWS , you can refer https://www.youtube.com/watch?v=oS7VYX7LXUo which talks about deploying a java application to AWS.
Let me know if you need any other information.

Deploying Java apps (for example, a Spring BOOT APP) that interacts with the Amazon Relational Database Service (Amazon RDS) to the cloud is easy when using Elastic Beanstalk. An example of a Spring Boot database application that queries data from MySQL running on the cloud is documented here: https://github.com/awsdocs/aws-doc-sdk-examples/tree/master/javav2/usecases/creating_secure_spring_app

Related

Azure - Java aplication

We are planning to deploy Java application ( using jax-ws) on Azure with Tomcat. But am not sure how to connect to On premises database on Azure in Java. Can someone please provide some pointers.
Thanks.
Assuming you will deploy your Java app in an Azure App Service, you have basically two options:
Use a hybrid connection
Use a VNET integrated App Service and connect to on-premise via VPN or Express Route

Deploying springboot app and ui separately

Currently, I have a springboot jar file with a bunch of rest and apis including calls for login deployed on ec2. I also have a separate code base for my ui i.e with js,html,css. What is the best way to deploy this on aws and keep it separate from the backend.
This can be done in many ways. But will share a simple way.
Deploy your spring boot app in one aws instance.
Deploy the other front end app on the other aws instance.
This is a kind of two tier application where the server and client app are hosted in different instance. You can restrict the access of your rest api to be accessed only by the instance where you host front end app. For trial you can use heroku account. E.g.
Github: https://github.com/krishna28/springbootapi
Also check https://github.com/krishna28/etodo

How to configure Glassfish on AWS Elastic Beanstalk, Connection Pool and Realm

I developed a Java EE 7 application, that uses Glassfish as the application server and MySQL as the database.
locally every thing is working correctly
now, I want to deploy the application to the cloud using AWS.
after reading some official documentations:
I created The database in the cloud 'AWS RDS', and conneted to it from MySQL Workbench and also The application in my workspace was able to connect to it and act on it.
Now for The application deployment I used Elastic Beanstalk with Glassfish 4.1 Java 8 (the docker one).
The probleme is that I need to configure Glassfish In AWS to
Create JDBC Connection Pool
Create JDBC Resource
Create A Security Realm
so that the apllication can work correctly.
How Can I do This?
I switch to Jelastic, I can access admin page usign their cloud, and I already deployed my appication

Amazon Web Service Deployment - free tier

I'm trying to use the AWS free tier for host a java web application. I created an EC2 instance but i don't figure out how can I deploy the application to this instance. I was trying to use the AWS Toolkit for eclipse to deploy the web site to Elastic Beanstalk, but from here i need a second tier to deploy the application to the production.
My question is: What is the free solution to make a deploy to my EC2 instance and how?
Thank you!
If you are using Elastic Beanstalk ( which I recommend), then you should create the Beanstalk stack manually from the AWS console. Before you do that, I suggest you to terminate your other instance, because you wont use that.
The beanstalk stack will create an EC2 instance in the background, also an RDS database if you ask for it. You pay for the resources ( EC2, RDS), but no extra cost for the "Beanstalk stack".
After you having the Beanstalk stack, you can deploy it with the Eclipse plugin, or just simply generate the WAR file and upload it via the AWS console. ( On the Beanstalk page there is a place to upload a war file for deployment.)
Be aware to set the DB connection details to the RDS ( if you are using it).
Also note that the free tier is nice to warm up but not recommended for production.
When you create the Beanstalk stack make sure you create a single AZ web frontend, so you will have only 1 webserver running.

How to connect to the local google cloud Datastore db?

I've GAE application which creates some data in the Google Cloud Datastore and stores some binary files into the Google Cloud Storage - let's call the application WebApp.
Now I have a different application running on the Google compute engine. Let's call the application ComputeApp.
The ComputeApp is a backend process which is processing data created by the WebApp. I asked here in this question previously which API can I use to communicate with Datastore from the ComputeApp. As suggested by #proppy, I implemented the Datastore communication using of the Google Cloud Datastore API.
Everything works fine as far as I'm communicating with the Datastore in the Google cloud. I'm using the service account authentication.
Now I need to run my ComputeApp locally, on my development PC so I'll take data created by my local WebApp and stored into the local debug Datastore. I need it because I want to have a testing environment so I can debug may GAE app locally.
How should I modify my ComputeApp code to force it to connect to my local debug Datastore instead of connect to the Google cloud?
I googled a lot and didn't find any advice nor example. Only possible way I found that I should rewrite my code completely and use a different API to do that. Such is Datastore Remote API.
Is this really only way? Should I really rewrite whole ComputeApp to connect to the local DB?
Really?
I hope that I just overlooked something important and It's not true...
Google Cloud Datastore has a local development server that you can use: https://developers.google.com/datastore/docs/tools/devserver
You can create and start the local datastore using the gcd tool which is linked to in the doc above.
If you use DatastoreHelper.getDatastoreFromEnv(); to build your Datastore, you can tell it to connect to your local database by exporting the env variable DATASTORE_HOST:
export DATASTORE_HOST=http://localhost:8080

Categories