Gathering detailed insights and metrics for @emilhdiaz/serverless-iam-roles-per-function
Gathering detailed insights and metrics for @emilhdiaz/serverless-iam-roles-per-function
Gathering detailed insights and metrics for @emilhdiaz/serverless-iam-roles-per-function
Gathering detailed insights and metrics for @emilhdiaz/serverless-iam-roles-per-function
Serverless Plugin for easily defining IAM roles per function via the use of iamRoleStatements at the function level.
npm install @emilhdiaz/serverless-iam-roles-per-function
Typescript
Module System
Min. Node Version
Node Version
NPM Version
73
Supply Chain
98.9
Quality
74.8
Maintenance
100
Vulnerability
99.6
License
TypeScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
1 Stars
56 Commits
3 Forks
1 Watchers
3 Branches
1 Contributors
Updated on Aug 05, 2020
Latest Version
1.0.4
Package Id
@emilhdiaz/serverless-iam-roles-per-function@1.0.4
Unpacked Size
69.79 kB
Size
14.32 kB
File Count
11
NPM Version
6.7.0
Node Version
11.10.0
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
A Serverless plugin to easily define IAM roles per function via the use of iamRoleStatements
at the function definition block.
npm install --save-dev serverless-iam-roles-per-function
Add the plugin to serverless.yml:
1plugins: 2 - serverless-iam-roles-per-function
Note: Node 6.10 or higher runtime required.
Define iamRoleStatements
definitions at the function level:
1functions: 2 func1: 3 handler: handler.get 4 iamRoleStatementsName: my-custom-role-name #optional custom role name setting instead of the default generated one 5 iamRoleStatements: 6 - Effect: "Allow" 7 Action: 8 - dynamodb:GetItem 9 Resource: "arn:aws:dynamodb:${self:provider.region}:*:table/mytable" 10 ... 11 func2: 12 handler: handler.put 13 iamRoleStatements: 14 - Effect: "Allow" 15 Action: 16 - dynamodb:PutItem 17 Resource: "arn:aws:dynamodb:${self:provider.region}:*:table/mytable" 18 ...
The plugin will create a dedicated role for each function that has an iamRoleStatements
definition. It will include the permissions for create and write to CloudWatch logs, stream events and if VPC is defined: AWSLambdaVPCAccessExecutionRole
will be included (as is done when using iamRoleStatements
at the provider level).
if iamRoleStatements
are not defined at the function level default behavior is maintained and the function will receive the global iam role. It is possible to define an empty iamRoleStatements
for a function and then the function will receive a dedicated role with only the permissions needed for CloudWatch and (if needed) stream events and VPC. Example of defining a function with empty iamRoleStatements
and configured VPC. The function will receive a custom role with CloudWatch logs permissions and the policy AWSLambdaVPCAccessExecutionRole
:
1functions: 2 func1: 3 handler: handler.get 4 iamRoleStatements: [] 5 vpc: 6 securityGroupIds: 7 - sg-xxxxxx 8 subnetIds: 9 - subnet-xxxx 10 - subnet-xxxxx
By default, function level iamRoleStatements
override the provider level definition. It is also possible to inherit the provider level definition by specifying the option iamRoleStatementsInherit: true
:
1provider: 2 name: aws 3 iamRoleStatements: 4 - Effect: "Allow" 5 Action: 6 - xray:PutTelemetryRecords 7 - xray:PutTraceSegments 8 Resource: "*" 9 ... 10functions: 11 func1: 12 handler: handler.get 13 iamRoleStatementsInherit: true 14 iamRoleStatements: 15 - Effect: "Allow" 16 Action: 17 - dynamodb:GetItem 18 Resource: "arn:aws:dynamodb:${self:provider.region}:*:table/mytable"
The generated role for func1
will contain both the statements defined at the provider level and the ones defined at the function level.
If you wish to change the default behavior to inherit
instead of override
it is possible to specify the following custom configuration:
1custom: 2 serverless-iam-roles-per-function: 3 defaultInherit: true
The plugin uses a naming convention for function roles which is similar to the naming convention used by the Serverless Framework. Function roles are named with the following convention:
<service-name>-<stage>-<function-name>-<region>-lambdaRole
AWS has a 64 character limit on role names. If the default naming exceeds 64 chars the plugin will remove the suffix: -lambdaRole
to shorten the name. If it still exceeds 64 chars an error will be thrown containing a message of the form:
auto generated role name for function: ${functionName} is too long (over 64 chars).
Try setting a custom role name using the property: iamRoleStatementsName.
In this case you should set the role name using the property iamRoleStatementsName
. For example:
1functions: 2 func1: 3 handler: handler.get 4 iamRoleStatementsName: my-custom-role-name 5 iamRoleStatements: 6 - Effect: "Allow" 7 Action: 8 - dynamodb:GetItem 9 Resource: "arn:aws:dynamodb:${self:provider.region}:*:table/mytable" 10 ...
Introduction post: Serverless Framework: Defining Per-Function IAM Roles
Note: Serverless Framework provides support for defining custom IAM roles on a per function level through the use of the role
property and creating CloudFormation resources, as documented here. This plugin doesn't support defining both the role
property and iamRoleStatements
at the function level.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/29 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
64 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More