This module helps in running complex series of dependent AWS API methods. There's not really any AWS specific logic here, it simply wraps the client objects provided by the AWS SDK and exposes an async stack interface for pushing named commands onto the stack, these can optionally include a callback that can in turn push more commands. Originally developed to support the specific use case of creating/viewing/destroying VPCs and their dependents (Internet Gateways, Subnets, NAT instances, etc.), see [list-clouds.js] for a related example.
npm install aws-command-stack
Find and release all of the unallocated VPC Elastic IP addresses in a region.
var AWSCommandStack = ;// configure clients (can be avoided with IAM Roles for EC2 Instances)var config =region: 'us-east-1'accessKeyId: 'AKyourAccessKeyId'secretAccessKey: 'yourSecretAccessKey';// create the stack, first argument is a list of which API clients to initializevar aws = 'EC2' config;aws;// push our first command, with a custom call backaws;// push our first commandaws;
You can use the included sample list-clouds.js to view a hierarchal list of all VPCs in a region (including subnets and instances):
% node list-clouds.js us-west-2us-west-2: found 1 Vpcsvpc-71cbe109 10.0.0.0/16 subnet-79cbe110 10.0.1.0/24subnet-7adbe112 10.0.0.0/24i-ea57cefd 10.0.0.162 18.104.22.168 
- simplified error handling, all callbacks will emit error params as error event on the stack object
- collapsed run/done into single next call