https://github.com/shelfio/serverless-simplify-default-exec-role-plugin
Fixes "IamRoleLambdaExecution - Maximum policy size of 10240 bytes exceeded" error
https://github.com/shelfio/serverless-simplify-default-exec-role-plugin
Last synced: 7 months ago
JSON representation
Fixes "IamRoleLambdaExecution - Maximum policy size of 10240 bytes exceeded" error
- Host: GitHub
- URL: https://github.com/shelfio/serverless-simplify-default-exec-role-plugin
- Owner: shelfio
- License: mit
- Created: 2021-12-24T22:06:37.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2024-02-28T08:42:25.000Z (almost 2 years ago)
- Last Synced: 2024-12-27T08:32:08.409Z (about 1 year ago)
- Language: JavaScript
- Size: 8.79 KB
- Stars: 6
- Watchers: 21
- Forks: 9
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: license
Awesome Lists containing this project
README
# serverless-simplify-default-exec-role-plugin
> Fixes "IamRoleLambdaExecution - Maximum policy size of 10240 bytes exceeded" error
This plugin works by modifying the Cloudformation stack before deployment.
It searches for the `IamRoleLambdaExecution` resource and modifies the only policy attached to this role.
## Install
```
$ yarn add --dev @shelf/serverless-simplify-default-exec-role-plugin
```
## Usage
In your `serverless.yml` file:
```yaml
plugins:
- '@shelf/serverless-simplify-default-exec-role-plugin'
```
## Explanation
By default, Serverless framework creates such role:
```json5
{
Effect: "Allow",
Action: ["logs:CreateLogStream", "logs:CreateLogGroup"],
Resource: [
{
"Fn::Sub": "arn:${AWS::Partition}:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/lambda/production-users-createUser:*",
},
{
"Fn::Sub": "arn:${AWS::Partition}:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/lambda/production-users-updateUser:*",
},
{
"Fn::Sub": "arn:${AWS::Partition}:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/lambda/production-users-deleteUser:*",
},
// dozens of identical lines
],
}
```
When you reach a certain project size, deployment will fail since this role will exceed 10 KB limit.
This plugin simplifies the default execution role to smth like this:
```json5
{
Effect: "Allow",
Action: ["logs:CreateLogStream", "logs:CreateLogGroup"],
Resource: [
{
"Fn::Sub": "arn:${AWS::Partition}:logs:${AWS::Region}:${AWS::AccountId}:log-group:*",
},
],
}
```
## Publish
```sh
$ git checkout master
$ yarn version
$ yarn publish
$ git push origin master --tags
```
## License
MIT © [Shelf](https://shelf.io)