Skip to content

Instantly share code, notes, and snippets.

@mdub
Last active December 23, 2018 14:12
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mdub/5654700 to your computer and use it in GitHub Desktop.
Save mdub/5654700 to your computer and use it in GitHub Desktop.
A simple Ruby-based AWS console
#! /usr/bin/env ruby
# This is free and unencumbered software released into the public domain.
#
# Anyone is free to copy, modify, publish, use, compile, sell, or
# distribute this software, either in source code form or as a compiled
# binary, for any purpose, commercial or non-commercial, and by any
# means.
require 'aws-sdk'
access_key_id = ENV.fetch("AWS_ACCESS_KEY_ID")
secret_access_key = ENV.fetch("AWS_SECRET_ACCESS_KEY")
region = ENV.fetch("AWS_DEFAULT_REGION", "ap-southeast-2")
config = {
:access_key_id => access_key_id,
:secret_access_key => secret_access_key,
:cloud_formation_endpoint => "cloudformation.#{region}.amazonaws.com",
:ec2_endpoint => "ec2.#{region}.amazonaws.com",
:elastic_beanstalk_endpoint => "elasticbeanstalk.#{region}.amazonaws.com"
}
AWS.config(config)
class AWSContext
def self.service(name, klass)
define_method(name) do
@services[name] ||= klass.new
end
end
def initialize
@services = {}
end
service :cloud_formation, AWS::CloudFormation
service :elastic_beanstalk, AWS::ElasticBeanstalk
service :ec2, AWS::EC2
service :s3, AWS::S3
end
require 'pry'
Pry.config.prompt = [proc { "AWS> " }, proc { "AWS| " }]
AWSContext.new.pry
@mdub
Copy link
Author

mdub commented Jun 3, 2013

Nice, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment