From ba765416f767cefe14d1d2aa03f934ed8472a082 Mon Sep 17 00:00:00 2001 From: David Wells Date: Thu, 10 Sep 2020 12:02:04 -0700 Subject: [PATCH 1/3] Throw if missing role name If rolename missing this passes through `undefined` and single `sls deploy -f funcNames` fail ``` Serverless: [AWS lambda 400 0.417s 0 retries] updateFunctionConfiguration({ FunctionName: 'service-dev-addNewUser', Description: 'Add user test function. Gated by imported Managed policy', Handler: 'examples/new-user.handler', Role: 'arn:aws:iam::01200101001:role/undefined' }) ``` --- lib/plugins/aws/deployFunction/index.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/plugins/aws/deployFunction/index.js b/lib/plugins/aws/deployFunction/index.js index 25963812576..6e7c4d995ab 100644 --- a/lib/plugins/aws/deployFunction/index.js +++ b/lib/plugins/aws/deployFunction/index.js @@ -79,6 +79,11 @@ class AwsDeployFunction { } const roleProperties = roleResource.Properties; + + if (!roleProperties.RoleName) { + throw new Error('Role resource missing RoleName properties'); + } + const compiledFullRoleName = `${roleProperties.Path || '/'}${roleProperties.RoleName}`; return this.provider From db0828903abaf328b31f77d01a0b4356027f778a Mon Sep 17 00:00:00 2001 From: David Wells Date: Thu, 10 Sep 2020 12:11:59 -0700 Subject: [PATCH 2/3] maybe fix lint? I'm in Github UI --- lib/plugins/aws/deployFunction/index.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/plugins/aws/deployFunction/index.js b/lib/plugins/aws/deployFunction/index.js index 6e7c4d995ab..cca628a7de7 100644 --- a/lib/plugins/aws/deployFunction/index.js +++ b/lib/plugins/aws/deployFunction/index.js @@ -77,13 +77,10 @@ class AwsDeployFunction { if (roleResource.Type !== 'AWS::IAM::Role') { throw new Error('Provided resource is not IAM Role.'); } - - const roleProperties = roleResource.Properties; - if (!roleProperties.RoleName) { throw new Error('Role resource missing RoleName properties'); } - + const roleProperties = roleResource.Properties; const compiledFullRoleName = `${roleProperties.Path || '/'}${roleProperties.RoleName}`; return this.provider From 8bfc5bac4ca266dc1304d8882523c49a25e4dd33 Mon Sep 17 00:00:00 2001 From: David Wells Date: Sat, 26 Sep 2020 12:21:52 -0700 Subject: [PATCH 3/3] use this.serverless.classes.Error --- lib/plugins/aws/deployFunction/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/plugins/aws/deployFunction/index.js b/lib/plugins/aws/deployFunction/index.js index cca628a7de7..a650e0a1230 100644 --- a/lib/plugins/aws/deployFunction/index.js +++ b/lib/plugins/aws/deployFunction/index.js @@ -77,10 +77,10 @@ class AwsDeployFunction { if (roleResource.Type !== 'AWS::IAM::Role') { throw new Error('Provided resource is not IAM Role.'); } + const roleProperties = roleResource.Properties; if (!roleProperties.RoleName) { - throw new Error('Role resource missing RoleName properties'); + throw new this.serverless.classes.Error('Role resource missing RoleName property'); } - const roleProperties = roleResource.Properties; const compiledFullRoleName = `${roleProperties.Path || '/'}${roleProperties.RoleName}`; return this.provider