Skip to content

Instantly share code, notes, and snippets.

@mmasashi
Created February 3, 2013 00:28
Show Gist options
  • Save mmasashi/4699906 to your computer and use it in GitHub Desktop.
Save mmasashi/4699906 to your computer and use it in GitHub Desktop.
change eip
#!/usr/bin/ruby
require 'aws-sdk'
EIP_ADDR="XX.XX.XX.XX"
INSTANCE_ID='i-XXXXXXXX'
ec2_info = {
:access_key_id => ENV['AWS_KEY_ID'],
:secret_access_key => ENV['AWS_SECRET_KEY']
}
ec2 = AWS::EC2.new(ec2_info)
eip = ec2.elastic_ips.find {|e| e.public_ip == EIP_ADDR}
eip.disassociate
eip.associate :instance => INSTANCE_ID
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment