Can I use DynamoDB through Heroku? - java

I am interested in using DynamoDB through Heroku. Will this work securely and how would I set up communication? I am using Java but help in any language would be fine.
Sources of info I've found thus far:
This question seems to imply it is possible without explaining how.
This question explains how Heroku can connect to elasticache (not DynamoDB) but goes on to explain that it is insecure as any Heroku application can connect to the elasticache server. I would like to make sure that however I connect to DynamoDB is, in fact, secure.
This video explaining how to connect to DynamoDB via Ruby in Heroku is no longer available.
This video keeps talking about how they're going to use DynamoDB from Heroku, and then the next presenter admits that he couldn't get something else to work and never went on to talk about using DynamoDB in Heroku.

Yes. You can indeed use DynamoDB with Heroku. I use it for a large application that handles about 15 billion requests per month.
Here's what you'll want to do:
Set your AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables in your Heroku app. When you sign up for AWS, you'll have to generate these if you have none already. Once you get them, store them in Heroku as environment variables.
Install a DynamoDB library in your language / framework of choice.
When you initialize your AWS library for DynamoDB, it will ask for 2 things: your AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY, so you can supply those from your environment variables.
The way this works in terms of security is like so:
Heroku runs on AWS in the us-east region.
If you create a DynamoDB instance in us-east, it will be in the same 'network' as your Heroku app.
When your Heroku app connects to DynamoDB, it will do so securely over SSL, using your AWS API keys as a username/password to connect.
When your Heroku app makes requests to DynamoDB, it will be very fast, as both your Heroku app and your DynamoDB instance are very close together physically.
Hope this helps =)

Related

Java code with CloudWatch or XRAY or IOT analytics?

New to AWS, I am writing a code for IDE in java so its desktop based application. I am trying to log some events in the application and I want it to be logged on cloud server. So, basically trying different services of aws. Tried for cloud watch, but it works on only aws applications. Trying to get more data on xray and IOT analytics. But no success. Can anybody suggest a proper solution.
Or is there a way that I can log the events somewhere on server and read through cloud watch.
Cloudwatch logs is the AWS native logging service. There are several ways to send data to it.
You can install an agent on your cloud/on-prem server and send logs to it.
Using the AWS API to send logs directly (you should probably use the SDK)
For either of those options, you will need to ensure you enable your application to access AWS. This is usually done by creating a user and role, and generating an access and secret key. There's a lot of nuance to doing this part correctly, so take your time.
The other tools you mentioned provide different services. XRAY is an Application Performance Monitoring tool that will let you get trace data and other insights into how your application runs. You usually correlate log data to this to help with debugging. IOT Analytics is specific to Internet Of Things / embedded devices and probably not a good fit for your Java app.

Unable to connect from ecllipse to cloud sql using app engine server and java

I am trying to connect from eclipse to cloud sql using app engine server, In SQL authorization I have added my ip address and given #anyhost access. I am using jdbc socketfactory to connect to cloud sql. But I am getting the below exception
please refer this link(exception screenshot)
Please provide error messages as actual text, not images. This makes searching for anything difficult. You also have your instance connection string in the image. I advise you to remove this.
As for answering your question, without more information I can give you a generalized answer.
When connecting from App Engine, you do not need to whitelist any IPs. Whitelisting IPs doesn't actually work with GAE as the IPs may change for new instances.
GAE instances have the Cloud SQL proxy running and you specify the connection details in your pom.xml.
Which exact connection method you need to use depends on your JAVA version, whether you're using GAE Standard or GAE Flexible, and if you're using a 1st or 2nd generation Cloud SQL instance.
This page provides links to details for all of the different scenarios to connect from GAE to Cloud SQL. For local testing of your app, you will have to have the Cloud SQL proxy running locally. This quickstart shows how to set this up.

how to create dev server on app-engine

I have a server running on app-engine. I am working on version 2 of my server, which serves as the backend for a mobile app. How do I a dev and a staging server so that I can test before replacing the production server? Does anyone know of a tutorial somewhere that addresses exactly this issue? It would be nice if I could set things up the way Google Play sets up android publication: I can publish to Alpha; then move the apk to Beta; and then to production. I will take what I can get at this point, but that structure would be nice.
You can use versions for this purpose. This way you can talk to myApp.appspot.com for a "production" version, to beta.myApp.appspot.com for a beta version, etc.
EDIT:
All versions run in different instances, but they all talk to the same datastore. It is a good option to test changes that do not break your data model - i.e. a beta version does not make changes in the datastore that break the production version.
If you want to test it in a local environment before pushing it to app engine. I would recommend have a separate box/server and deploy your code there and run the application on that server. Run application as web application in debug mode so you can see errors or problems that occurs. Connect your phone via Wi-Fi to your LAN and make sure the port you are using such as 8080 is open in your hub/firewall.
This way your server's services can send data and receive data without actually deploying on app engine.
This link might be useful:
https://developers.google.com/appengine/docs/java/tools/devserver
I implement using http://www.streamhead.com/google-appengine-staging-server/. It's better than versioning. But thanks everyone for helping.

Desktop app connecting to a remote Amazon RDS mysql instance

I have a java swing desktop app that needs to connect to a remote mysql instance over jdbc. I was thinking of using Amazon RDS for this and creating a security group with an IP of 0.0.0.0 - effectively allowing all IPs to connect to the mysql instance.
I understand that there are security implications with this approach and we should ideal front a remote database with a web application. The desktop app should access the web application via rest/soap and then get access to the db behind it via services exposed by the web app.
Now that's a lot of work. Since I already have the desktop app connecting to a local DB. I just want to move the DB over onto the cloud so that a user can access the same DB from any other system where the same java swing app is installed.
Could someone help me by listing out the security implications on exposing an Amazon RDS DB out on the internet like this?
Also, more importantly, are there any ways of eliminating these risks? Such as SSH Tunneling for example?
The best method is the SSH Tunneling using the KEY that generates by Amazon.
You can also open an ip with the mask IP of 23.43.65.0/24 and also create a VPN with your desktop and Amazon.
I know that when I leave a DB open to the world, which I don't normally do, 24 hours a day, 7 days a week automated process keep trying to login in about 10-15 times per second, all day, every day guessing user names and passwords.
If you go this route, which I don't recommend, better make sure your passwords are very, very hard to guess and if you can rename the built-in accounts to something other than 'admin' or 'administrator' all the better.

How to run a Java server on Amazon's EC2?

I want to place a server program written in Java on the cloud. It would accept TCP socket connections from clients (clients are android phones using 3G), do some computations, save stuff to a MySQL database (also on EC2), and send stuff back to the clients over the TCP connections. It may even be necessary to create several instances of the server (i.e. a process group).
Is this easy to do? I think I can make a AMI, but I'm not sure how to upload Java files, compile and run them, and create a MySQL database etc
Any help would be much appreciated.
Take a look at using Amazon Elastic Beanstalk. Beanstalk is Amazon's PaaS offering and it will alleviate a lot of the system administration burden. Here's a quick description from their docs:
AWS Elastic Beanstalk is an even
easier way for you to quickly deploy
and manage applications in the AWS
cloud. You simply upload your
application, and Elastic Beanstalk
automatically handles the deployment
details of capacity provisioning, load
balancing, auto-scaling, and
application health monitoring.
Also, if you're interested in using MySQL then you should look at Amazon RDS. Again, this will alleviate the system administration burden for your database tier. Here's a quick description from their docs:
Amazon Relational Database Service
(Amazon RDS) is a web service that
makes it easy to set up, operate, and
scale a relational database in the
cloud. It provides cost-efficient and
resizable capacity while managing
time-consuming database administration
tasks, freeing you up to focus on your
applications and business.
Is this easy to do? I think I can make
a AMI, ...
I think the answer depends on how comfortable you are with system administration in general. Creating a AMI to run in EC2 is really pretty much the same as creating a physical server or a VM image. You'll need to install an operating system, and then install tools, libraries and programs you need (like mysql, the jdk, ssh, etc).
You can save yourself a little work by using one of Amazon's pre-built AMI's http://aws.amazon.com/amis/. But, ultimately, you'll be responsible for all system administration of the server. If you've never built a server from the ground up, you have a pretty big learning curve ahead of you. It's not insurmountable, but just be warned that the devil is in the details; there's a ton of stuff you'll need to learn ;-)
... but I'm not sure how to upload Java
files, compile and run them, ...
Once the server is setup and running in EC2, compiling them and running java files is just the same as compiling and running on your local. Normally, you probably want to compile and package your java app into a jar or war and then transfer that up to your EC2 server. If you install linux os on your EC2 server, you can use scp or a FTP client to transfer your files over sftp to move the files from your local up to the server. Once the latest files are up on your server, you can ssh to the server and start your app.
... and create a MySQL database etc ...
Installing mysql is going to be specific to the OS you choose to install on your server. For example, you can install mysql easily on Ubuntu with a command like:
sudo aptitude install mysql
Again, there will be more system-admin-type stuff to learn here specific to mysql databases.
So, it's definitely doable. An experienced sys admin could build a AMI instance pretty easily/quickly. If this is your first experience with system administration, I'd suggest finding an old Desktop you have lying around and try installing Ubuntu and all the required libraries and tools you need (mysql, jdk, ssh, etc..). Get your java program working on the old desktop and then it should be pretty easy to create an AMI from that. Then you can run your custom AMI on EC2 and will be set up.
If you don't have a spare desktop lying around, you can use one of the Virtual Machine products like VMWare Player or Sun's VirtualBox and build a server instance on one of those.
If you want to avoid the hassle of managing the entire install of the Operating system, you might want to look at services like slicehost and/or linode instead of EC2. They give you ssh access to a pre-installed server. And it's as easy as clicking a button to install programs like mysql, etc.
Hope this answer is relevant and helpful, good luck.
- Dave
If you can use Tomcat as your server - you might want to try Amazon Web Services Elastic Beanstalk It will greatly simplify your task by providing an easy instance of Tomcat to deploy.
EDIT: AWS has a full section on how to develop using Java here: http://aws.amazon.com/java/
How comfortable are you with remote administering a server and solving problems most people have never heard of? That's what you're talking about.
You'll create your EC2 instance, log into it and configure it like you would any other server you're working with. You can download JDKs to it, dbs etc. You might consider using a tool like Chef to help you. You'll use ftp and scp to copy files to the server.
You're probably going to want your Java server on one box and have it talk to a separate db server since you say you may want multiple servers.
Once the server is working the way you like it you can create an image of it to use to launch multiple instances, then configure a load balancer to point at your servers.
If you can create a MySql db on your local box you can create it in the cloud. If not?....
Running Applications needs app. s/w to run them.
Apps such as Cyber Duck helps to upload files via SFTP.
I am successful in doing the same problem addressed.. Trust me, YOU CAN DO IT. All u need is interfaces for server services such as MySQL (use WorkBench to connect using key pair), terminal access (using PUTTY/SSH via MAC) and well you are good to go
I think to get started is to use a a whole unit packed into one archive.
Think of it as you have your Java files compiled, a embedded http server say tomcat. Now all of this packed in a jar ready to be deployed on Amazon's EC2. Use this link for more on embedded servers and relevant code.
As far as database is concerned, you can use Amazon's RDS. You can configure mysql on RDS and obtain a link to it for connection. Amazon RDS would help you to get started with database.
Now that you have everything ready to start and work with application. Now is the time to deploy on Amazon AMI
Perform Following steps to deploy you app on Amazon EC2:
Create a server instance on Amazon EC2 refer EC2 getting started.
Receive Private key file i.e. .pem(receive from Step 1), this file would help you to login to your server instance and perform SFTP.
Use Putty or similar SSH client to login to your EC2 server instance created on Step-1 using .pem file and server's public DNS, refer Accessing Instance for SSH login.
Transfer the archived files packed into jar to server using SFTP client, WinnSCP being one such client, refer SFTP for more on it.
Run application. Note in case of jar file you can simply fire java -jar TomcatApp.jar.
If everything is configured properly you would be to access the app using EC2 instance's public DNS or public IP, which would be of the form:
http://<public_dns_address>:<port number>/servlet
Hope it helps you to get started and provide you an overall view.

Categories