Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin fails starting from Serverless v2.5.0 #52

Closed
KnupMan opened this issue Oct 7, 2020 · 26 comments · Fixed by #53
Closed

Plugin fails starting from Serverless v2.5.0 #52

KnupMan opened this issue Oct 7, 2020 · 26 comments · Fixed by #53

Comments

@KnupMan
Copy link

KnupMan commented Oct 7, 2020

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: serverless/serverless#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.

@KnupMan KnupMan changed the title Plugin doesn't work starting from Serverless v2.5.0 Plugin fails starting from Serverless v2.5.0 Oct 7, 2020
@hawkaa
Copy link

hawkaa commented Oct 7, 2020

Just ran into the same issue!

@Bril-Sls
Copy link

Bril-Sls commented Oct 7, 2020

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

@blairg23
Copy link

blairg23 commented Oct 7, 2020

I am experiencing this issue as well.

@drgomesp
Copy link

drgomesp commented Oct 7, 2020

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.

@amitpn805
Copy link

Use this :
"serverless-iam-roles-per-function": "2.0.2",

@randomhash
Copy link
Collaborator

@amitpn805 it will fail for 2.5.0

use 2.4.0< version of serverless for now

@siovaneDAZN
Copy link

siovaneDAZN commented Oct 8, 2020

Same issue here this.awsPackagePlugin.validateStatements is not a function

Use this :
"serverless-iam-roles-per-function": "2.0.2",

That doesn't work in my case

@thava
Copy link

thava commented Oct 9, 2020

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

This is the only workaround which worked for me for now.

@arthurmarcal
Copy link

Same problem here .

@mucyomiller
Copy link

same problem here .

@andersquist
Copy link
Collaborator

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

@mdrijwan
Copy link

mdrijwan commented Oct 15, 2020

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

@Enase
Copy link
Collaborator

Enase commented Oct 15, 2020

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

@MontoyaAndres
Copy link

any updated?

@andrewnicolalde
Copy link

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 :)

@glicht
Copy link
Member

glicht commented Oct 30, 2020

Hi, sorry for being non responsive. I will take a look at the PR.

As I am currently limited in time for the project, I am looking to add an additional maintainer for the project. If someone is interested please let me know.

@theburningmonk
Copy link
Collaborator

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

@randomhash
Copy link
Collaborator

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

@andersquist
Copy link
Collaborator

@glicht The same here! 🙂

@Enase
Copy link
Collaborator

Enase commented Oct 30, 2020

@glicht The same for me. Contribution in portfolio #25

@glicht
Copy link
Member

glicht commented Nov 2, 2020

@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.

@glicht glicht mentioned this issue Nov 2, 2020
@davidfells
Copy link

davidfells commented Nov 23, 2020

@glicht Even updating to @next, I see this:

Serverless: Configuration warning:
Serverless: at 'functions.rulesSeedQueue': unrecognized property 'iamRoleStatements'
Serverless: at 'functions.rulesDisable': unrecognized property 'iamRoleStatements'
Serverless: at 'functions.rulesFetchAndExecute': unrecognized property 'optimize'
Serverless: at 'functions.rulesFetchAndExecute': unrecognized property 'iamRoleStatements'
Serverless: at 'functions.pricingInsert': unrecognized property 'iamRoleStatements'
Serverless: at 'functions.pricingUpdate': unrecognized property 'iamRoleStatements'
Serverless:
Serverless: Learn more about configuration validation here: http://slss.io/configuration-validation

And

Serverless Error ---------------------------------------

An error occurred: RulesSeedQueueIamRoleLambdaExecution - The policy failed legacy parsing (Service: AmazonIdentityManagement; Status Code: 400; Error Code: MalformedPolicyDocument; Request ID: 16349a14-d7e1-4fd6-bb3e-383aac6add83; Proxy: null).

The app in question had worked fine until updating to latest Serverless, no changes have been made. Nothing is being created at all in AWS. Here's my config: https://gist.github.com/davidfells/681ffb43a42a73da0522c2df69692d34

@vladholubiev
Copy link

@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....

@davidfells
Copy link

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.

@mdrijwan
Copy link

npm i serverless-iam-roles-per-function@next

@samuelcastro
Copy link

samuelcastro commented Dec 17, 2021

Was this fixed @theburningmonk ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet