How do i get the Elastic IP from running instance?

0 votes

I am running a  java application running on an EC2 instance. I want to know what my own elastic IP address that was manually assigned from the management console. Is there a way to query EC2 API for this?

Aug 29, 2018 in AWS by datageek
• 2,390 points

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

If yours is a linux ec2 instance this should work:



Java Code:

public static String getIP() throws IOException, InterruptedException {
    Process p = Runtime.getRuntime().exec("curl");
    int returnCode = p.waitFor();
    if ( returnCode == 0 ) {
        BufferedReader r = new BufferedReader(new InputStreamReader(p.getInputStream()));
        String ip = r.readLine();
        return ip;
    else {
        //handle error
        return null;

answered Aug 29, 2018 by Archana
• 3,770 points

Related Questions In AWS

0 votes
1 answer
+1 vote
2 answers

How do I get my AWS Glue client in JAVA?

Hey, you've been using a correct code ...READ MORE

answered Apr 17, 2018 in AWS by Cloud gunner
• 4,240 points
+1 vote
2 answers

How do I run python script on aws EC2 instance(ubuntu)?

I believe that you are using the ...READ MORE

answered Apr 17, 2018 in AWS by Cloud gunner
• 4,240 points
0 votes
1 answer

Unable to connect to chromedriver on Amazon Linux AMI server

The issue seems to be only with ...READ MORE

answered Mar 26, 2018 in Selenium by nsv999
• 5,030 points
+3 votes
1 answer

aws cloudformation for atomic stack-update

When you perform a stack update, only ...READ MORE

answered Mar 27, 2018 in AWS by DareDev
• 6,520 points
+5 votes
2 answers

EC2 instance status check failed

Creating a snapshot from an EBS volume ...READ MORE

answered Mar 27, 2018 in AWS by DragonLord999
• 8,360 points
+1 vote
3 answers

How can I connect an app with an aws ec2 instance?

This is how you deploy a web ...READ MORE

answered Oct 18, 2018 in DevOps & Agile by Hannah
• 14,080 points
0 votes
1 answer

How can I find out the instance id of an ec2 instance from within the ec2 instance?

On Amazon Linux AMIs you can do: $ ...READ MORE

answered Sep 10, 2018 in AWS by Archana
• 3,770 points
0 votes
1 answer

How to copy a folder from S3 to Elastic Beanstalk instance on its creation?

I had encountered similar problem. But i ...READ MORE

answered Aug 24, 2018 in AWS by Archana
• 3,770 points

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.