serverless-iam-roles-per-function: Plugin fails starting from Serverless v2.5.0

Serverless just released a new version of the npm package (https://github.com/serverless/serverless/releases/tag/v2.5.0) and the plugin started to fail with following error:

Error & stack trace
Type Error ---------------------------------------------
 
  TypeError: this.awsPackagePlugin.validateStatements is not a function
      at ServerlessIamPerFunctionPlugin.validateStatements (/home/circleci/repo/node_modules/serverless-iam-roles-per-function/dist/lib/index.js:49:31)
      at ServerlessIamPerFunctionPlugin.createRoleForFunction (/home/circleci/repo/node_modules/serverless-iam-roles-per-function/dist/lib/index.js:189:14)
      at ServerlessIamPerFunctionPlugin.createRolesPerFunction (/home/circleci/repo/node_modules/serverless-iam-roles-per-function/dist/lib/index.js:284:18)
      at /snapshot/serverless/lib/classes/PluginManager.js:510:55
  From previous event:
      at PluginManager.invoke (/snapshot/serverless/lib/classes/PluginManager.js:510:22)
      at /snapshot/serverless/lib/classes/PluginManager.js:545:24
  From previous event:
      at PluginManager.run (/snapshot/serverless/lib/classes/PluginManager.js:545:8)
      at /snapshot/serverless/lib/Serverless.js:168:33
  From previous event:
      at Serverless.run (/snapshot/serverless/lib/Serverless.js:155:74)
      at /snapshot/serverless/scripts/serverless.js:50:26
      at processImmediate (internal/timers.js:456:21)
      at process.topLevelDomainCallback (domain.js:137:15)
  From previous event:
      at Object.<anonymous> (/snapshot/serverless/scripts/serverless.js:50:4)
      at Module._compile (pkg/prelude/bootstrap.js:1320:22)
      at Object.Module._extensions..js (internal/modules/cjs/loader.js:1156:10)
      at Module.load (internal/modules/cjs/loader.js:984:32)
      at Function.Module._load (internal/modules/cjs/loader.js:877:14)
      at Module.require (internal/modules/cjs/loader.js:1024:19)
      at Module.require (pkg/prelude/bootstrap.js:1225:31)
      at require (internal/modules/cjs/helpers.js:72:18)
      at Object.<anonymous> (/snapshot/serverless/bin/serverless.js:47:1)
      at Module._compile (pkg/prelude/bootstrap.js:1320:22)
      at Object.Module._extensions..js (internal/modules/cjs/loader.js:1156:10)
      at Module.load (internal/modules/cjs/loader.js:984:32)
      at Function.Module._load (internal/modules/cjs/loader.js:877:14)
      at Function.Module.runMain (pkg/prelude/bootstrap.js:1375:12)
      at internal/main/run_main_module.js:17:47

I found a PR, which caused this error: https://github.com/serverless/serverless/pull/8297 Basically, the method, which was used to validate the iam statements, was removed from serverless package at all, so there should be a different way to validate the statements in order to align with the new versions of serverless.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 30
  • Comments: 26 (2 by maintainers)

Most upvoted comments

@theburningmonk @randomhash @andersquist @Enase thanks for offering your help. Really appreciated. I’ve added you to the repo with write access. So you will be able to approve and merge PRs.

Additionally, I’ve just deployed a pre-release of version 3.0.0 with the latest merged PRs: https://www.npmjs.com/package/serverless-iam-roles-per-function/v/3.0.0-d84bffd

I am also looking into automating the deployment process so at least for the next we will get an auto deploy once merged to master.

Ran into this issue as well. We were able to find a temporary workaround by locking the version of serverless framework installed to a previous version. npm i serverless@2.4.0 -g

@glicht I’m happy to help out. I depend on this project a lot.

I’ve fixed the builds and failing tests for the PR and the package as a whole. If anyone feels inclined to review the PR I’d be so happy. 🙏

Meanwhile I’ve published a temporary package under the innovative name of serverless-iamroles for my own purposes with these fixes incorporated. Until this gets fixed/merged be happy to use it if you like: https://www.npmjs.com/package/serverless-iamroles

Was this fixed @theburningmonk ?

Use this : “serverless-iam-roles-per-function”: “2.0.2”,

Master version specifies no lock on the version (https://github.com/functionalone/serverless-iam-roles-per-function/blob/master/package.json). Is this on purpose?

"serverless": "^1.51.0",

Therefore if any breaking changes are introduced, say from 2.4.0 to 2.5.0, you will have to deal with that.

@glicht Hello. Also would be glad to help. Heavily dependable on this project

any updated?

@glicht The same here! 🙂

I’ve fixed the builds and failing tests for the PR and the package as a whole. If anyone feels inclined to review the PR I’d be so happy. pray

Meanwhile I’ve published a temporary package under the innovative name of serverless-iamroles for my own purposes with these fixes incorporated. Until this gets fixed/merged be happy to use it if you like: https://www.npmjs.com/package/serverless-iamroles

@glicht Would also enormously appreciate it if you guys could merge this PR 😃

It’s a critical bug for community that might be fixed in one click (and later you may implement the correct solution). why not?

facing the same problem here as well

Serverless: Packaging service...
Serverless: Excluding development dependencies...
Serverless: Excluding development dependencies...
Serverless: Injecting required Python packages to package...

  Type Error ---------------------------------------------

  TypeError: this.awsPackagePlugin.validateStatements is not a function
      at ServerlessIamPerFunctionPlugin.validateStatements (/Users/rijwan/code/g2g/serverless-python-order/node_modules/serverless-iam-roles-per-function/src/lib/index.ts:62:27)
      at ServerlessIamPerFunctionPlugin.createRoleForFunction (/Users/rijwan/code/g2g/serverless-python-order/node_modules/serverless-iam-roles-per-function/src/lib/index.ts:209:10)
      at ServerlessIamPerFunctionPlugin.createRolesPerFunction (/Users/rijwan/code/g2g/serverless-python-order/node_modules/serverless-iam-roles-per-function/src/lib/index.ts:306:12)
      at /Users/rijwan/.nvm/versions/node/v12.18.4/lib/node_modules/serverless/lib/classes/PluginManager.js:510:55
      at tryCatcher (/Users/rijwan/.nvm/versions/node/v12.18.4/lib/node_modules/serverless/node_modules/bluebird/js/release/util.js:16:23)
      at Object.gotValue (/Users/rijwan/.nvm/versions/node/v12.18.4/lib/node_modules/serverless/node_modules/bluebird/js/release/reduce.js:168:18)
      at Object.gotAccum (/Users/rijwan/.nvm/versions/node/v12.18.4/lib/node_modules/serverless/node_modules/bluebird/js/release/reduce.js:155:25)
      at Object.tryCatcher (/Users/rijwan/.nvm/versions/node/v12.18.4/lib/node_modules/serverless/node_modules/bluebird/js/release/util.js:16:23)
      at Promise._settlePromiseFromHandler (/Users/rijwan/.nvm/versions/node/v12.18.4/lib/node_modules/serverless/node_modules/bluebird/js/release/promise.js:547:31)
      at Promise._settlePromise (/Users/rijwan/.nvm/versions/node/v12.18.4/lib/node_modules/serverless/node_modules/bluebird/js/release/promise.js:604:18)
      at Promise._settlePromise0 (/Users/rijwan/.nvm/versions/node/v12.18.4/lib/node_modules/serverless/node_modules/bluebird/js/release/promise.js:649:10)
      at Promise._settlePromises (/Users/rijwan/.nvm/versions/node/v12.18.4/lib/node_modules/serverless/node_modules/bluebird/js/release/promise.js:729:18)
      at _drainQueueStep (/Users/rijwan/.nvm/versions/node/v12.18.4/lib/node_modules/serverless/node_modules/bluebird/js/release/async.js:93:12)
      at _drainQueue (/Users/rijwan/.nvm/versions/node/v12.18.4/lib/node_modules/serverless/node_modules/bluebird/js/release/async.js:86:9)
      at Async._drainQueues (/Users/rijwan/.nvm/versions/node/v12.18.4/lib/node_modules/serverless/node_modules/bluebird/js/release/async.js:102:5)
      at Immediate.Async.drainQueues [as _onImmediate] (/Users/rijwan/.nvm/versions/node/v12.18.4/lib/node_modules/serverless/node_modules/bluebird/js/release/async.js:15:14)
      at processImmediate (internal/timers.js:456:21)

     For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.

  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com

  Your Environment Information ---------------------------
     Operating System:          darwin
     Node Version:              12.18.4
     Framework Version:         2.5.0
     Plugin Version:            4.0.4
     SDK Version:               2.3.2
     Components Version:        3.2.1

Just ran into the same issue!

On the warning, thanks.

Not sure how I lost my pesudo parameters plugin and didn’t catch it in Git, but adding it back resolved the issue. Thanks again.

@davidfells the first warning is b/c Serverless validates serverless.yml and doesn’t know about custom properties this plugin relies onto. So ignore it. It’s expected to see that warning.

Regarding the 2n error, it has nothing to do with this plugin either. 1st result in Google yielded this - https://stackoverflow.com/a/51728883/2727317

And it applies to your config. You’re using #{AWS::AccountId} to substitute account id. But I don’t see you have https://www.serverless.com/plugins/serverless-pseudo-parameters/ plugin in your config…