How to get Elastic IP address of servers behind Load Balancer - amazon-web-services

I have a couple of servers behind an amazon load balancer and I need to find out their elastic IP addresses so I can SSH into them. (I'm on a different computer than normal and have left my amazon hardware authenticator back home in a different country so I can't just log into the AWS console).
Is there any way of obtaining these two addresses?

This may be a long shot, since you're not on your usual computer, but do you have the command line tools installed?
aws elb describe-instance-health --load-balancer-name <ELB name>
Returns a list of instances connected to the ELB.
aws ec2 describe-instances <instance id>
Returns among other things the IP address of the instance. If you have your Access Key and Secret Key you can set up the command line tools and skip the AWS console.
EC2 tools: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/SettingUp_CommandLine.html
ELB tools: http://docs.aws.amazon.com/ElasticLoadBalancing/latest/DeveloperGuide/UsingTheCommandLineTools.html
UPDATE: As of this edit the ELB Command Line tools have been replaced in favour of AWS CLI: http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-set-up.html
Documentation for AWS CLI with ELB commands

Related

AWS - cannot find Lighsail instance in EC2

I created a WordPress app using Lightsail. It says it was created in Frankfurt Zone. However, I cannot see this instance in EC2 console. I want to create a Load Balancer for that app and add certificates, but I can't cause I don't see this instance on the list. Any ideas where can I find this Lightsail instance in EC2 console?
AWS Lightsail not shown in EC2 console, it's the main difference between the Lightsail and EC2, If you want to have more control on your EC2, so you should run EC2 instance instead of cheaper version Lightsail.
For more info about the Lighsail read the FAQ on the AWS website:
https://aws.amazon.com/lightsail/faq/
Also, you can use Lightsail load balancer instead of standard ELB on AWS, for more info read the following doc:
https://aws.amazon.com/lightsail/features/load-balancing/

looking for IP address in amazon aws

I just handed over a project which technical responsible person quit.
My client asked me to fix problem on their service they just know which domain but none of server ip and how to access.
Since they uses aws I looked for ip address which digged from domain but can't find in Ec2, load balancer and elastic ip.
By IP search, this ip address is served by amazon aws.
How can I find this server from ip address.
I can access to my customer's aws account.
I can access dns of customer's service domain.
It seems that your situation is:
You have a domain name that points to an IP address
You wish to find the EC2 instance(s) that the IP address points to
An IP address could be associated with:
An EC2 instance IP address
An Elastic IP address, which is then associated with an EC2 instance
Not a load balancer (it uses a DNS Name, not an IP address -- except for the new Network Load Balancer, but it is unlikely they are using this)
An database instance (eg RDS, Redshift, Elasticache) but this is unlikely as you are saying that the IP address is responding with web traffic
Therefore, the best thing to do would be to use the AWS Command-Line Interface (CLI) to list all IP addresses on EC2 instances and Elastic IPs:
aws ec2 describe-instances --query Reservations[*].Instances[*].[InstanceId,PublicIpAddress] --output text
aws ec2 describe-addresses --query Addresses[*].[NetworkInterfaceId,PrivateIpAddress] --output text
Run the above commands in every Region and you should find where that particular IP address is pointing.
First of all go to the billing section of the AWS Account and verify there are EC2 instances running under the AWS account provided to you.
Username in menu bar (top right corner) -> My Billing Dashboard -> Bills -> Details -> Elastic Compute Cloud -> Region of your EC2 instances
If you find instances in a particular region by switching to it and then you should be able to find the EC2 instance and SSH/RDP to it using the Key.pem file given to you(Or need to request it from your customer)

Connect to AWS EC2 after restarting

I want to stop and restart my AWS EC2 instance daily. I can stop it through the API command line interface, but to reconnect I need to get the new DNS information so that I can connect through Remote Desktop. Is there a way to reconnect that doesn't involve going through the EC2 Management Console?
Option 1
Assign an Elastic IP address to the instance, and always connect via that IP.
You can also then setup a DNS record with a friendly name (e.g. myinstance.mydomain.com) pointing to that elastic IP address.
Note that while your instance is stopped, having a reserved elastic IP address assigned to it will cost a small hourly charge - see https://aws.amazon.com/ec2/pricing/on-demand/#Elastic_IP_Addresses for more information.
Option 2
If you're using route53 for DNS management (or some other DNS hosting service which has an API you can use), you could write a script that runs at instance startup which detects its current IP address, and uses the route53 api to update a DNS record with the instances new IP address. You'd need to take into account the DNS propagation time if doing this, so I'd definitely recommend the Elastic IP method over this if possible.
Option 3
Use the AWS CLI with the following commands to get the public IP address of your instance. Be sure to change the instance-id parameter to match your own instance.
aws ec2 describe-instances --instance-id i-0a3bd317964ca45543 --query 'Reservations[0].Instances[0].PublicIpAddress'
For example, combining that with an SSH command might look like this:
ssh ec2-user#`aws ec2 describe-instances --instance-id i-0a3bd317964ca45543 --query 'Reservations[0].Instances[0].PublicIpAddress' --output text` -i ~/my-key.pem

how to get public IP addresses for a specific account using APIs in Amazon Web Services (AWS)

I want to retrieve all the public IP addresses that have been allocated to an Amazon Web Services account.
There are two types of public IP addresses:
Elastic IP addresses (static)
Auto-assigned IP addresses (which might change if an instance is Stopped & Started)
Also, many different services are assigned IP addresses:
Amazon EC2 instances
Amazon RDS instances
Amazon Elasticache instances
Amazon Redshift instances
Amazon EMR master node
Elastic Load Balancer (the IP addresses change and should never be cached/stored)
etc
You would need to perform describe commands against each individual service to retrieve IP address information. There is no command that can retrieve this information across all services.
You might be able to use an AWS Config configuration snapshot -- it might have the information you seek for most services.
Example: Fetching Elastic IP Addresses
The easiest way to obtain a listing of Elastic IP Addresses (which are static addresses assigned to EC2 instances) is to use the AWS Command-Line Interface (CLI), which has a describe-addresses command:
aws ec2 describe-addresses --region ap-southeast-2
To obtain a list of Instance IDs and IP addresses:
$ aws ec2 describe-addresses --region ap-southeast-2 --query 'Addresses[*].[InstanceId,PublicIp]' --output text
i-0c9c9394b3583afdc 54.222.207.37
i-0ef605853622f705e 54.79.149.39
The command would need to be issued for each region separately. (You could create a script that loops through them all.)

Assigning Elastic IP to Auto-Scaled EC2 in VPC - AWS

My goal is to automatically assign an elastic IP to an auto-scaled EC2 instance.
I have done the following:
- Configured EC2 instance w/ startup script to assign IP
- Configured launch config and auto-scale group per spec.
The issue is that when deploying the auto-scaled launch config I lose the ability to allow it to automatically assign a public address (at first) before it picks up the elastic IP assignment.
When I deploy the AMI manually, provided that I check that "assign public IP address" box, the instance will deploy, temporarily assign the xxxx.amazon.xxxx address, then roll over to my elastic IP assignment.
however..
when deployed through the auto-scale command line utilities (as-create-launch-config + as-create-auto-scaling-group) the IP will not work. I feel it could be fixed if there was an option when setting up the launch config to temporarily grab a public IP in order to communicate with the amazon API to pull the elastic assignment.
I greatly appreciate your help!
You may want to use cloud-init to run a command on the local autoscaled server that attaches the EIP. Here is an example of a local command running on a server on first boot: http://cloudinit.readthedocs.org/en/latest/topics/examples.html#run-commands-on-first-boot
In that local command you could use amazon's built in tools to associate the address: http://docs.aws.amazon.com/AWSEC2/latest/CommandLineReference/ApiReference-cmd-AssociateAddress.html
In the launch config, add that cloud-init syntax to the user-data attribute as base64 encoded and all future autoscaled instances will do exactly what the cloud-init states it will do.
I usually base64 encode by doing:
base64 <filename>