serverless-plugin-custom-roles
v3.1.1
Published
A Serverless plugin that makes creation of per function IAM roles easier
Downloads
13,446
Maintainers
Readme
serverless-plugin-custom-roles
A Serverless plugin that makes creation of per function IAM roles easier. It mimics serverless behavior, but creates separate roles for each function instead of a shared one. If you want to create per function roles without using this plugin, you are responsible for providing the corresponding permissions for your function logs and stream events and need to repeat the same permissions from function to function.
Usage
service: my-service
plugins:
- serverless-plugin-custom-roles
provider:
name: aws
iam:
role:
statements: # [Optional] these statements will be applied to all functions
- Effect: "Allow"
Action:
- "xray:PutTraceSegments"
- "xray:PutTelemetryRecords"
Resource: "*"
permissionsBoundary: "arn:aws:iam::123456789012:policy/boundaries" # [Optional] the ARN of the policy used to set the permissions boundary for the role
functions:
function1:
handler: 'src/function1.js'
iamRoleStatements: # [Optional] these statements will be applied to this function only (in addition to statements that are applied to all functions)
- Effect: "Allow"
Action:
- "cloudwatch:GetMetricStatistics"
- "cloudwatch:DescribeAlarms"
- "cloudwatch:PutMetricData"
Resource: "*"
function2:
handler: 'src/function2.js'
events:
- stream: # Appropriate permissions will be applied automatically
type: dynamodb
arn: "<stream-arn>"
License
The MIT License (MIT)
Copyright (c) 2018-2022 Anton Bazhal
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.