aws-lambda - 发生错误:IamRoleLambdaExecution - 角色的最大策略大小超过 10240 字节
问题描述
在 serverless.yml 中使用 serverless-plugin-split-stacks 并收到此错误
发生错误:IamRoleLambdaExecution - 角色 Vkonnect-dev-ap-south-1-lambdaRole 的最大策略大小超过 10240 字节(服务:AmazonIdentityManagement;状态代码:409;错误代码:LimitExceeded;请求 ID:51920d55-4b81-4b6c- 99f1-d9f0ba087cc2;代理:空)。
当我使用serverless-plugin-custom-roles
我得到这个错误
CloudFormation 模板无效:资源之间的循环依赖:[GenerateOtpDocLambdaPermissionApiGateway, DoctorUnderscorelistLambdaPermissionApiGateway ......]
无服务器.yml
service: Vkonnect #Name of your App
provider:
name: aws
runtime: nodejs14.x # Node JS version
memorySize: 128
timeout: 10
stage: dev
region: ap-south-1 # AWS region
deploymentBucket:
name: vkonnectlayers
# iamRoleStatements:
# - Effect: "Allow"
# Action:
# - "s3:*"
# Resource:
# NOTE you can't refer to the LogicalID of S3Bucket, otherwise
# there will be a circular reference in CloudFormation
iamRoleStatements:
- Effect: "Allow"
Action:
- "cloudformation:*"
- "codecommit:*"
- "apigateway:*"
- "execute-api:Invoke"
- "execute-api:ManageConnections"
- "cloudformation:DescribeStacks"
- "cloudformation:ListStackResources"
- "cloudwatch:ListMetrics"
- "cloudwatch:GetMetricData"
- "ec2:DescribeSecurityGroups"
- "ec2:DescribeSubnets"
- "ec2:DescribeVpcs"
- "kms:ListAliases"
- "iam:GetPolicy"
- "iam:GetPolicyVersion"
- "iam:GetRole"
- "iam:GetRolePolicy"
- "iam:ListAttachedRolePolicies"
- "iam:ListRolePolicies"
- "iam:ListRoles"
- "lambda:*"
- "logs:DescribeLogGroups"
- "states:DescribeStateMachine"
- "states:ListStateMachines"
- "tag:GetResources"
- "xray:GetTraceSummaries"
- "xray:BatchGetTraces"
Resource:
- "*"
- "arn:aws:apigateway:*::/*"
- "arn:aws:events:*:*:rule/codecommit*"
- "arn:aws:logs:*:*:log-group:/aws/lambda/*"
plugins:
- serverless-offline
- serverless-layers
- serverless-plugin-split-stacks
- serverless-plugin-custom-roles
# - serverless-nested-stack
package:
individually: true
exclude:
- ./**
custom:
splitStacks:
perFunction: false
perType: false
perGroupFunction: true
nestedStackCount: 5
serverless-layers: # All Layers
- moment:
name: moment
excludeDevDependencies: false
individually: true
dependenciesPath: ./layers/moment-layer/package.json
package:
patterns:
- /**
- "!node_modules/**"
解决方案
对于策略大小限制错误:
AWS 对策略大小有限制。查看这篇文章以供参考:https ://aws.amazon.com/premiumsupport/knowledge-center/iam-increase-policy-size/
对于循环依赖错误:
推荐阅读
- java - 获取设备的当前语言
- python - 将列名与给定列的值连接起来
- androidx - org.greenrobot.greendao.DaoException 在使用 androidx 时 android 发布模式
- wordpress - 如何在文章的特色图片、图片和画廊上插入和显示版权所有者字段?
- python-3.x - 如何在pyqt5中将函数输出设置为信号
- java - 如何将我的字符串(表示十六进制值)转换为字节?
- mysql - 在 Sequelize 的 findAll() 查询中同时使用包含和属性的问题
- windows - 如何像在 Linux 中一样在 git bash 中按向上/向下翻页启用历史搜索?
- javascript - Chrome.storage.onchnage 不起作用 Chrome 扩展
- android - Flutter 未更新其动画文本小部件 (Animated_Text_kit)