Skip to content

Instantly share code, notes, and snippets.

@youpy
Created February 23, 2010 06:38
Show Gist options
  • Select an option

  • Save youpy/311939 to your computer and use it in GitHub Desktop.

Select an option

Save youpy/311939 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
if ARGV.size != 1
warn "usage: #{$0} instance_name"
exit 1
end
instance_name = ARGV.shift
values = `rds-describe-db-instances`.split(/[\r\n]+/).grep(/^DBINSTANCE/).map do |line|
line.split(/\s+/)
end.find do |values|
values[1] == instance_name
end
if values
_, _, _, _, engine, _, user, _, host, port = values
if engine =~ /mysql/i
exec "mysql -u #{user} -h #{host} -P #{port} -p"
end
else
warn "#{instance_name}: no such instance"
exit 1
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment