Skip to content

Instantly share code, notes, and snippets.

@ashayh
Forked from kntyskw/Assign me a VIP
Created August 6, 2014 19:23
Show Gist options
  • Select an option

  • Save ashayh/984baf0dbb252d3b847d to your computer and use it in GitHub Desktop.

Select an option

Save ashayh/984baf0dbb252d3b847d to your computer and use it in GitHub Desktop.
#!/bin/sh
VIP=$1
IF=$2
# Determine the interface's MAC address
MAC=`ip link show $IF | awk '/ether/ {print $2}'`
# Determine ENI ID of the interface
ENI_ID=`curl http://169.254.169.254/latest/meta-data/network/interfaces/macs/$MAC/interface-id`
# Set the current region as default
export AWS_DEFAULT_REGION=`curl http://169.254.169.254/latest/meta-data/placement/availability-zone | rev | cut -c 2- | rev`
aws ec2 assign-private-ip-addresses\
--network-interface-id $ENI_ID\
--private-ip-addresses $VIP\
--allow-reassignment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment