Awsm gives you a mongodb-like interface for controlling AWS.
Here's how:
var aws = ; // let's go ahead and provision a few ubuntu instances around the globe.awsallstart;
How about migrating a pre-existing image? Easy:
awsall { awsimages;};
Awsm is also extendable. Want to add SSH? No problem:
var aws = ;aws
Want a command line interface? This is not the repository you're looking for. Checkout awsm-cli.
Plugins
- awsm-keypair-save - allows you to save keypairs locally immediately after creating them.
- awsm-ssh - super nice utility that allows you to ssh, execute scripts, and rsync files on your EC2 instances.
Node API
awsm awsm(config)
Initializes the awsm library.
key
- aws keysecret
- aws secretec2
- the ec2 configregions
(array) - regions to use (["us-east-1", "us-west-1", ...])
log
- log configlevel
- the log level to use -notice
,verbose
,warn
,error
Resource Collections
Resource collections share a common API, and are used for every object type which includes regions
, instances
, images
, securityGroups
, and keyPairs
.
collection.find(query, callback)
Finds many resources in the target collection.
// find all U.S. regionsawsmec2regions; // find all running instances in a given regionregioninstances;
collection.findOne(query, callback)
Finds one resource against a target collection.
// find an image with the given nameregionimages;
Available Collections
Below are a list of available collections to search against
awsm.ec2.instances
-all
instances acrossall
regions.awsm.ec2.images
-all
images acrossall regions
.awsm.ec2.regions
-all
regions.region.instances
- instances specific to the region.region.images
- images specific to the region.
EC2 Regions
Awsm allows you to interface against multiple EC2 regions pretty easily - all you need to do is pass which regions you want to use in the main config.
var aws =
Note that the regions
property is completely optional - awsm will automatically default to all
EC2 regions if the property is omitted.
Here are a few examples of how you might interact with awsm regions:
// init awsmvar awsm = ; // get all regionsawsmec2regionsallonAllRegions; // find all U.S. regionsawsmec2regions; // find ALL instances in ALL regionsawsmec2instancesallonAllInstancesFromAllRegions; // find ALL RUNNING instances in ALL regionsawsmec2instances;
EC2 Tags
Allows you to tag specific instances, images, security groups, or key pairs.
resource.tags.update(tags, next)
Updates the tags on the specific resource
instancetags
EC2 Instances
region.instances.create(options, callback)
Creates a new instance in the target region.
imageId
- (required) imageId to usecount
- (default = 1) number of instances to createflavor
- (default = t1.micro) type of instance to use (t1.micro, m1.medium)securityGroup
- (optional) the security group object to use with the instancekeyPair
- (optional) the key pair object to use with the instance
regioninstances
instance.start(callback)
starts the instance
instance.restart(callback)
restarts the instance
instance.stop(callback)
stops the instance
instance.createImage(options, callback)
creates an image out of the instance
instance.getVolumes(callback)
returns all the volumes attached to the instance
instance.getSecurityGroups(callback)
returns all the securityGroups attached to the instance
instance.getAddress(callback)
returns the allocated address assigned to the specific instance
instance.getImage(callback)
returns the image used to create the instance
instance.getKeyPair(callback)
returns the keypair assigned to the instance
tags instance.tags
instance tags collection
instance.destroy(callback)
destroys the instance
EC2 Images
region.images.create(options, callback)
creates a new image
image.createInstance(options, next)
creates a new instance from the image
image.migrate(regions, next)
migrates the image to another region
image.destroy(callback)
destroys the image
EC2 Addresses
region.addresses.create(options, callback)
allocates a new address
address.attach(instance, callback)
associates an address with an instance
address.detach(instance, callback)
detaches from an instance
address.getInstance(callback)
returns the instance associated with the address
tags address.tags
address tags collection
address.destroy(callback)
releases the address
EC2 Volumes
region.volumes.create(options, callback)
creates a new volume
volume.attach(instance, callback)
attaches to an instance
volume.detach(callback)
detaches from an instance
volume.getInstances(instance, callback)
returns all the instances this volume is attached to
volume.createSnapshot([description, ]callback)
creates a new snapshot of the volume
volume.destroy(callback)
destroys the volume
EC2 Snapshots
region.snapshots.create(options, callback)
creates a snapshot
snapshot.createVolume(options, callback)
creates a volume out of the snapshot
snapshot.getVolume(callback)
returns the snapshot associated with the given volume
snapshot.destroy(callback)
destroys the snapshot
EC2 Key Pairs
region.keyPairs.create(options, callback)
creates a new keypair
keyPair.destroy(callback)
destroys the keypair
EC2 Security Groups
region.securityGroups.create(options, callback)
creates a security group
securityGroup.authorize(port, callback)
authorizes a port in the security group
securityGroup.revoke(port, callback)
revokes port
securityGroup.destroy(callback)
destroys the security group.
Chaining
TODO - Checkout the examples at the top.