Features
- Easily migrate images to other AWS regions
- Mongodb-like terminal utility
- Ability to chain ec2 commands
- Built-in terminal helpers
- ssh directly into instances via
instances().find(query).limit(1).ssh()
- ability to save key-pairs to disc via
keyPairs().create(name).save()
- make your own!
- ssh directly into instances via
- Support for
key pair
,instance
,image
,security group
, andaddress
APIs
TODO
- ability to clone instances
- spot requests
- watch spot pricing
Terminal Usage
Usage: ectwo [commands...] -c [config] -p [profile] -r [regions] Options: -r regions to use -i interactive [default: false] -c configuration location [required] [default: "/usr/local/etc/ectwo/conf"] -p profile to use [required] [default: "default"]
You'll first need to define your configuration file in /usr/local/etc/ectwo/conf.js
. Here's a template:
moduleexports = "profiles": "default": "regions": "us-east-1" "us-west-1" "key": "AWS_KEY" "secret": "AWS_SECRET" "another-profile": "key": "AWS_KEY" "secret": "AWS_SECRET"
profiles
are used to help ectwo
determine what account to use.
Examples
Creating a new key-pair, and saving to disc:
$ ectwo -r us-east-1 "keyPairs().create('some-key').save()" ↩
------------------------------------
Profile: default
Regions: us-east-1
------------------------------------
us-east-1.keyPairs()
us-east-1.keypairs.create("some-key") .. 2.79 s
us-east-1.some-key.save()
[
{
"_id": "some-key",
"name": "some-key",
"region": "us-east-1",
"fingerprint": "FINGERPRINT",
"material": "MATERIAL"
}
]
save keypair to /Users/craig/keys/us-east-1/some-key.pem
Finding all images across all regions:
$ ectwo -r us-east-1 "images().find()" ↩------------------------------------ Profile: defaultRegions: us-west-1, us-west-2, us-east-1, eu-west-1, sa-east-1, ap-southeast-1, ap-southeast-2, ap-northeast-1 ------------------------------------ [ ]
You can also run ectwo
in interactive mode by adding the -i
flag. For example:
$ ectwo -r us-east-1 -i ↩------------------------------------ Profile: defaultRegions: us-east-1 ------------------------------------ > us-east-1.addresses.find us-east-1.54.225.244.40.attach .. 2.50 s[ ]> us-east-1.instances.find us-east-1.i-b43313de.pluck [ ]>
Node API
ectwo(config)
config
- configurationregions
- (optional) - regions to usekey
- AWS keysecret
- AWS secret
var ectwo = regions: "us-east-1" key: "AWS_KEY" secret: "AWS_SECRET";
Collections API
collection.findOne(query, cb)
Performs a search for an item. The query parameter expects a mongodb query.
//find all US regionsectworegions;
collection.find(query, cb)
Finds multiple items
collection.wait(query, cb)
Wait for the query condition to be met before calling cb
.
collection.reload(cb)
reloads the collection. Collections are cached by default.
Regions API
region.instances
instances collection
//return all instancesregioninstancesall { };
region.images
images collection
region.addresses
addresses collection
region.keyPairs
keyPairs in a region
region.securityGroups
security groups in a region
Instances API
instances.create(options, next)
creates one, or many instances
options
imageId
- image ID to usecount
- (optional) number of instances to createkeyName
- (optional) key name to usesecurityGroupId
- (optional) security group ID to useflavor
- (optional) flavor of instance (t1.micro, m1.small, etc.)
instances;
value instance.get(property)
returns a propertly value of the instance.
_id
- id of the instanceimageId
- the image idregion
- the region this instance is instate
- the state of the instance. Possible states:running
- instance is runningpending
- initializingstopped
- instance is stoppedterminated
- instance is terminatedshutting-down
- instance is shutting downstopping
- instance is stopping
type
- the instance type (t1.micro, m1.medium, m1.small, etc.)address
- assigned addressdnsName
- dns namearchitecture
- i386, x86_64tags
- instance tags (array)key
- tag keyvalue
- tag value
instance.start(cb)
Starts an instance
instancestart { console; //running};
instance.stop(cb)
Stops an instance
instance
instance.restart(cb)
Restarts an instance
instance
instance.destroy(cb)
Destroys an instance
instance;
instance.createImage(cb)
Creates an image out of the instance
instance.tag(key, value, cb)
Creates / deletes / updates tag.
//createinstance;
instance.address(cb)
Returns the address assigned to the instance. If no address is assigned, the result will be null.
instance;
instance.image(cb)
returns the image associated with the instance
instance;
instance.resize(type, cb)
resizes an instance
instance;
instance.status(cb)
returns the status of the instance
Images API
value image.get(property)
_id
- id of the imageregion
- the region this image is instate
- image state -pending
, orcompleted
name
- name of the imagetype
- type of imagekernelId
- image kernel IDplatform
-windows
, orlinux
architecture
- i386, x86_64descrption
- description of the imagetags
- image tags - same format as instances
image.migrate(regions, cb)
Migrates the image to another region
images;
image.createInstance(options, cb)
Creates an instance out of the image. Options are the same as instance.create
.
Addresses API
addresses.create(cb)
creates a new address
regionaddresses;
value address.get(property)
_id
- id of the addresspublicIp
- public IPinstanceId
- the instance this address is assigned to
address.attach(instanceId, cb)
associates an address with an instance
address.detach(cb)
disassociate an address with an instance
instance;
Key Pair API
keyPairs.create(name, cb)
Creates a new key pair.
regionkeyPairs;
value keyPair.get(property)
_id
- the key pair IDname
- the key pair namefingerPrint
- the key pair finger printregion
- the region this keyPair belongs tomaterial
- the key material - only returned onkeyPairs.create()
Security Group API
securityGroups.create(name, cb)
regionsecurityGroups;
value securityGroup.get(property)
_id
- the security group IDname
- the security group namedescrption
- the security group descriptionpermissions
- security group permissions
securityGroup.authorize(portOrOptions, cb);
securityGroup;securityGroup;
securityGroup.revoke(portOrOptions, cb);
Opposite of authorize
.
Chaining
ectwo also supports chaining. Here are a few examples:
//find ALL images, migrate them to us-west-2, then launch themectwoimages; //stop redis instancesectwo