packages/iam/src/index.js
function loadPolicy(documentPath, name) {
  return plugin.myrmex.fire('beforePolicyLoad', documentPath, name)
  .spread((documentPath, name) => {
    // Because we use require() to get the document, it could either be a JSON file
    // or the content exported by a node module
    // But because require() caches the content it loads, we clone the result to avoid bugs
    // if the function is called twice
    const document = _.cloneDeep(require(documentPath));
    const Policy = require('./policy');
    const policy = new Policy(document, name);

    // This event allows to inject code to alter the Lambda configuration
    return plugin.myrmex.fire('afterPolicyLoad', policy);
  })
  .spread((policy) => {
    return Promise.resolve(policy);
  });
}
function loadPolicy(documentPath, name) {
  return plugin.myrmex.fire('beforePolicyLoad', documentPath, name)
  .spread((documentPath, name) => {
    // Because we use require() to get the document, it could either be a JSON file
    // or the content exported by a node module
    // But because require() caches the content it loads, we clone the result to avoid bugs
    // if the function is called twice
    const document = _.cloneDeep(require(documentPath));
    const Policy = require('./policy');
    const policy = new Policy(document, name);

    // This event allows to inject code to alter the Lambda configuration
    return plugin.myrmex.fire('afterPolicyLoad', policy);
  })
  .spread((policy) => {
    return Promise.resolve(policy);
  });
}
function loadPolicy ( documentPath , name ) { return plugin . myrmex . fire ( 'beforePolicyLoad' , documentPath , name ) . spread ( ( documentPath , name ) => { // Because we use require() to get the document, it could either be a JSON file // or the content exported by a node module // But because require() caches the content it loads, we clone the result to avoid bugs // if the function is called twice const document = _ . cloneDeep ( require ( documentPath ) ) ; const Policy = require ( './policy' ) ; const policy = new Policy ( document , name ) ; // This event allows to inject code to alter the Lambda configuration return plugin . myrmex . fire ( 'afterPolicyLoad' , policy ) ; } ) . spread ( ( policy ) => { return Promise . resolve ( policy ) ; } ) ; }
Load a policy
@param {string} documentPath - path to the document file
@param {string} name - the policy name
@returns {Promise<Policy>} - the promise of a policy
Load a policy