lhrslsshahi
asked on
Unable to disassociate and associate elastic IP address EC2-VPC
I am trying to setup HA Proxy and KeepAlived in AWS using the following article http://www.devopstech.com/haproxy-failover-keepalived-aws-ec2/
The master script in the article is for EC2-Classic and not EC2-VPC.
I have attached the script that I am working on any help would be appreciated.
aws ec2 associate-address --instance-id i-b6dcf92f --allocation-id eipalloc-3e380501 --public-ip 23.22.679.245
An error occurred (InvalidParameterCombinati on) when calling the AssociateAddress operation: You may specify public IP or allocation id, but not both in the same call.
EC2-VPC-script.txt
The master script in the article is for EC2-Classic and not EC2-VPC.
I have attached the script that I am working on any help would be appreciated.
aws ec2 associate-address --instance-id i-b6dcf92f --allocation-id eipalloc-3e380501 --public-ip 23.22.679.245
An error occurred (InvalidParameterCombinati
EC2-VPC-script.txt
ASKER
I need to able to assign the specific public IP 23.22.679.245 from 1 instance to another the above assigns a random Elastic IP. Also when you run the script the disassociate command works the first time around but when it changes the ASSOCIATION_ID=eipassoc-07 a97e38 to another it fails as it doesnt recognise the new ASSOCIATION_ID.
Below is lb1
#!/bin/bash
EIP=23.22.679.245
INSTANCE_ID=i-b6dcf92f
ASSOCIATION_ID=eipassoc-07 a97e38
ALLOCATION_ID=eipalloc-3e3 80501
/usr/bin/aws ec2 disassociate-address --association-id $ASSOCIATION_ID
/usr/bin/aws ec2 associate-address --instance-id $INSTANCE_ID --allocation-id $ALLOCATION_ID
-------------------------- ----
lb2
#!/bin/bash
EIP=23.22.679.245
INSTANCE_ID=i-b6dcf92f
ASSOCIATION_ID=eipassoc-07 a97e38
ALLOCATION_ID=eipalloc-3e3 80501
/usr/bin/aws ec2 disassociate-address --association-id $ASSOCIATION_ID
/usr/bin/aws ec2 associate-address --instance-id $INSTANCE_ID --allocation-id $ALLOCATION_ID
Below is lb1
#!/bin/bash
EIP=23.22.679.245
INSTANCE_ID=i-b6dcf92f
ASSOCIATION_ID=eipassoc-07
ALLOCATION_ID=eipalloc-3e3
/usr/bin/aws ec2 disassociate-address --association-id $ASSOCIATION_ID
/usr/bin/aws ec2 associate-address --instance-id $INSTANCE_ID --allocation-id $ALLOCATION_ID
--------------------------
lb2
#!/bin/bash
EIP=23.22.679.245
INSTANCE_ID=i-b6dcf92f
ASSOCIATION_ID=eipassoc-07
ALLOCATION_ID=eipalloc-3e3
/usr/bin/aws ec2 disassociate-address --association-id $ASSOCIATION_ID
/usr/bin/aws ec2 associate-address --instance-id $INSTANCE_ID --allocation-id $ALLOCATION_ID
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks Phil worked a treat. The only other thing I had to do was to change from /usr/bin/aws to /bin/aws.
I'm glad it worked! Remember to close the question. Thanks!
ASKER
Thank you very much again Phil.
Open in new window