nl_tokens: Uses IAM . getInstanceProfile to check the existence of the instanceProfile . If the response comes back with instanceProfile 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 instanceProfile does not exist and the promise is resolved with False . All other errors result in a rejection .
pl_tokens: function doesInstanceProfileExist ( iam , instanceProfileName ) { function inspectError ( err ) { if ( err . code === 'NoSuchEntity' ) { return <mask> } return Bluebird . reject ( err ) } return iam . getInstanceProfilePromised ( { InstanceProfileName : instanceProfileName } ) . then ( _ . constant ( true ) ) . error ( inspectError ) }