Saturday, 10 June 2017

Retrieve IP from AWS SDK describeAddresses

I'm trying to get the Ip of my AWS EC2 instance in a var, from a remote Node server. The describeAddresses function works well but I can't find a way to get the IP outside the callback. In particular:

function getIP() {
    var return_ip;
    var response = ec2.describeAddresses(ip_params,function(err, data){
        if (err) {
            console.log("Error", err);
        } else {
            //console.log("Success", data.Addresses);
            var IP = data.Addresses[0].PublicIp;
            //This is the IP I should access outside
        }
    });
    //return return_ip;
}

I can't add any parameter in ip_params nor in the callback nor in the describeAddresses function (as all these are defined in the SDK itself).

All help and pointers appreciated !



via Zick

No comments:

Post a Comment