nl_tokens: Uses EC2 . describeSecurity groups to check the existence of the security group . If the response comes back successful doesSecurityGroupExist is resolved with True . If an operational error occurs in the underlying ec2 client call the error is inspected to see if it is an InvalidGroup . NotFound error . This means the security group is not present so doesSecurityGroupExist is resolved with false . All other errors are propagated along via a rejection .
pl_tokens: function doesSecurityGroupExist ( ec2 , securityGroupName ) { function inspectError ( err ) { if ( err . code === 'InvalidGroup.NotFound' ) { return <mask> } return Bluebird . reject ( err ) } return ec2 . describeSecurityGroupsPromised ( { GroupNames : [ securityGroupName ] } ) . then ( _ . constant ( true ) ) . error ( inspectError ) }