Can someone provide some CLI commands to move an Elastic IP between servers in AWS? I have the AWS EC2 CLI command for associate/disassociate and it requires an association ID. How do I get that? As well, I have 2 NIC's in each server (instance)...how do I tell AWS to associate the Elastic IP with the right NIC?
To allocate EIP to the ENI you will have to use --network-interface-id check this link for details
https://docs.aws.amazon.com/cli/latest/reference/ec2/create-network-interface.html.
And you can get association ID for the EIP from the console check this screenshot.
Or you can achieve that from command line.
https://docs.aws.amazon.com/cli/latest/reference/ec2/describe-addresses.html
aws ec2 associate-address --region us-east-1 --allocation-id eipalloc-xxx --allow-reassociation --network-interface-id eni-xxx
Related
I am trying to launch node in EC2 VPC using chef knife ec2 server create to launch ec2 instance into VPC, But I looking a flag to specify vpc info.
Anyone know how to spin up ec2 instance into vpc using knife ec2 server create ?
Thanks
There is a --subnet SUBNET_ID flag for knife ec2 command. You can specify which subnet of VPC you want the instance be created using this flag.
Refer: https://docs.chef.io/plugin_knife_ec2.html
You cannot provide VPC identity. However, you can provide subnet identity which eventually will create the instance in your VPC of choice.
Is it possible to tell an Amazon EC2 Instance to reconnect the IP?
I know there are scripts to tell a local router (e.g. at home) to reconnect and assign a new IP adress. Is there something similar to the Amazon VMs?
In essence what you are referring to is actually using Elastic IPs.
Basically you reserve an IP address and you can associate and disassociate it from a EC2 instance as you please. You will be able to use that IP as long as you don't release it. (Initially you need to allocate that IP address)
You can also do all the Elastic IP operations programmatically using the AWS API and any of the available SDKs (Java, Ruby, Python, PHP, etc) or using the AWS CLI
For example:
# Allocate Address
aws ec2 allocate-address
# Associate Address
aws ec2 associate-address --instance-id <Your Instance ID> --public-ip <IP Address>
# Disassociate Address
aws ec2 disassociate-address --public-ip <IP Address>
# Release Address
aws ec2 release-address --public-ip <IP Address>
My specific need is to get the list of EC2 instances in the deployment from within one of the instances.
I've tried using AWS command line for example aws elb describe-load-balancers however it would just give details of all my AWS services. I know you can specify an instances name with --load-balancer-name but I just don't have access to that from within the instance automatically.
Perhaps a file can be created on instance creation by placing something in .ebextensions?
You can do it in a two step process using the AWS CLI.
First you get the endpoint for your Elastic Beanstalk application:
aws elasticbeanstalk describe-environments --query='Environments[?ApplicationName==`Your-application-name`].EndpointURL'
Then you use the endpoint to get the instances:
aws elb describe-load-balancers --query='LoadBalancerDescriptions[?DNSName==`load-balancer-end-point-from-previous-step`].Instances[0]'
Hey is it possible to change the external IP address of my Amazon EC2 instance without restarting the thing?
Any help would be appreciated, the reason why I want to do this is because restarting will charge me for the full hour.
Yes, you can associate/disassociate an Elastic IP without restarting the EC2 instance. It can be done from the "Elatic IPs" screen of the AWS Management Console, EC2 section.
I have some instances with an EC2 VPC (using only ip addresses from RFC 1918) that need to use some services of EC2 via CLI interface (ec2-describe-instances, ec2-run-instances, etc)
I can't get it to work : my understanding is that the service point of the CLI interface is located somewhere in AWS cloud and my requests originating from an RFC1918 address are not routable in the AWS cloud between EC2 service point and my instance.
Is that correct ?
Is my only solution to install a NAT instance within my VPC (I would like to avoid it) ? Or could I get a way to remap this Ec2 service point within my VPC on a RFC1918 address
Any help welcome !
Thanks in advance
didier
You can give the instance an elastic IP address and get outbound access to other publicIPs, like the EC2 API endpoint. Make sure your security group doesn't allow any inbound traffic from the Internet.
Alternatively, if you don't want to use an EIP, you can launch an instance in a VPC with a publicIP address. more here: http://aws.typepad.com/aws/2013/08/additional-ip-address-flexibility-in-the-virtual-private-cloud.html