Skip to content

Instantly share code, notes, and snippets.

@kntyskw
Created April 19, 2013 00:01
Show Gist options
  • Save kntyskw/5417140 to your computer and use it in GitHub Desktop.
Save kntyskw/5417140 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