Skip to content

Instantly share code, notes, and snippets.

@jyidiego
Created December 9, 2015 21:58
Show Gist options
  • Save jyidiego/1ec3bc3dba60141970b6 to your computer and use it in GitHub Desktop.
Save jyidiego/1ec3bc3dba60141970b6 to your computer and use it in GitHub Desktop.
Simple script to associate Elastic IP to a EC2 instances in the public subnet
#!/bin/bash
REGION=$(curl http://169.254.169.254/latest/meta-data/placement/availability-zone 2>/dev/null)
INSTANCE_ID=$(curl http://169.254.169.254/latest/meta-data/instance-id 2>/dev/null)
aws configure set region ${REGION%[a-z]}
aws ec2 associate-address --instance-id $INSTANCE_ID --allocation-id <allocation id>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment