aws-existence v0.1.1
aws-existence
Methods which simplify checking whether or not AWS resources exist.
Usage
var ex = require('aws-existence')
var ec2 = ex.ec2({region: 'us-west-2'})
ec2.doesSecurityGroupExist('mySecurityGroup')
.then(doSomething)
function doSomething(exists) {
if (exists) {
// DESTROY IT!!!
} else {
// MAKE IT!!!
}
}
There are several other methods which also work like this. I'm sorry but for now you just have to look at the source to see which ones are available. Hundreds still need to be developed, and I'd appreciate any and all help.
Checking if a resource exists with the SDK is absurdly difficult!
It should be this easy:
- You should ask
doesMyResourceExist
. - Pass something which identifies that type of resource uniquely.
- Receive a Promise which is resolved to
true
if the resource exists, andfalse
if it doesn't.
That's it!
Working Around the Problem
There are only a few aws-sdk clients which provide methods for checking existence.
I know s3.doesBucketExist
is a thing, but I can't remember any others off the top of my head. This module
is built from the opinion that this is an oversight, there should always have been existence checking methods in
the sdk.
There are a few ways to work around the problem, but unfortunately the sdk clients differ enough, to be more annoying than useful. But that's why this module exists to hide that annoyance.
existence inconsistencies
- Multiple method conventions:
get*
,describe*
, andlist*
methods. - Plural vs Singular:
describeInstances
,describeTable
,getRole
- Responses: Objects, Collections
non-existence inconsistencies
- Generic Exceptions
ResourceNotFoundException
- Specific Exceptions
NoSuchEntity
,LoadBalancerNotFound
, orInvalidGroup.NotFound
. - Null response
- Empty collection:
[ ]
It's all further complicated because each client takes specific and varying params as well.
Disclaimer
This is a Work In Progress, no promise is made about completeness. Please contribute new methods!
Install
npm install --save aws-existence