nl_tokens: Uses IAM . getRole to check the existence of the role . If the response comes back with role data the promise is resolved with True . If an error occurs the err is inspected to see if it is a NoSuchEntity / 404 error . If it is this means the role does not exist and the promise is resolved with False . All other errors result in a rejection .
pl_tokens: function doesRoleExist ( iam , roleName ) { function inspectError ( err ) { if ( err . <mask> === 'NoSuchEntity' ) { return false } return Bluebird . reject ( err ) } return iam . getRolePromised ( { RoleName : roleName } ) . then ( _ . constant ( true ) ) . error ( inspectError ) }