serverless-heaven / serverless-aws-alias

Alias support for Serverless 1.x
MIT License
189 stars 68 forks source link

Error while trying to deploy project with Custom Roles for each Lambda #106

Closed iamNoah1 closed 2 years ago

iamNoah1 commented 6 years ago

Hei guys,

I am trying to deploy a project which instead of using global IAM roles, has custom roles for each Lambda. Doing so results in the following Error:

Cannot read property 'Properties' of undefined

Relevant Part of the Stacktrace:

TypeError: Cannot read property 'Properties' of undefined at AwsAlias.module.exports (.../node_modules/serverless-aws-alias/lib/stackops/lambdaRole.js:40:13) at AwsAlias.aliasHandleLambdaRole (.../node_modules/serverless-aws-alias/lib/aliasRestructureStack.js:43:21)

I don't know if this related to custom IAM Roles for each Lambda Function or to using IAM Roles in general. Short debugging showed that stageStack.Resources here does not contain a IamRoleLambdaExecution property, while a simple hello world serverless project does.

Seems that the respective object in the CloudFormation template JSON has a static name (IamRoleLambdaExecution) only if no custom roles are defined. Otherwise the respective object has the name of the role.

Please correct me if I am wrong, and let me know if you have any idea what I maybe have done wrong, or need more information to investigate on this. If you don't have time, let me also know maybe I have the time to do further investigation and open a PR.

Cheers Noah

HyperBrain commented 6 years ago

Hi @MeBNoah . Nice catch.

Just checked the code and saw that service roles are handled correctly (if (_.has(this._serverless.service.provider, 'role')) {) but it seems that per lambda roles are currently not (maybe I just forgot this case).

It would be cool if you can give a PR a try and investigate the issue. The main point here is, that you should check if this happens also with external roles or also with custom roles defined within the service.

iamNoah1 commented 6 years ago

Hi @HyperBrain,

I will have a look if I finde some time for it :) ... thx for the input.

Cheers Noah

jmb12686 commented 5 years ago

Any progress on this? I seem to be having the same issue that this PR #145 is supposed to fix (custom roles, same stack, for each lambda function)

sakichan commented 5 years ago

Any progress on this? I seem to be having the same issue that this PR #145 is supposed to fix (custom roles, same stack, for each lambda function)

Hi @jmb12686,

My PR won't be applied because its coverage tests failed. BTW, @HyperBrain has no activity record on github since last October. So, I gave up the use of serverless-aws-alias and removed it from my project.

lkolchin commented 4 years ago

Any update on this? I'm using Custom roles for each function and that really breaks my deployments!