aws / aws/serverless-application-model
The final policy size is bigger than the limit
- Dominant language
- Python
- Stars
- 9.6k
- Forks
- 2.5k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 7
Description
I have created a SAM template that contains a lot of API events for one function
When I deploy it to CFN, I have the following error :
17:14:03 UTC+0100 | CREATE_FAILED | AWS::Lambda::Permission | MyApiPutAdminLoginsResourcePermissionProd | The final policy size (20851) is bigger than the limit (20480).
Is there a way to avoid that ?
The first strange thing to me is : why does it creates one permission per resource instead of one permission for the whole API ?
The second strange thing for me is that it creates 2 permissions for each resource like
MyApiPutAdminLoginsResourcePermissionTest + MyApiPutAdminLoginsResourcePermissionProd. Why does it duplicate the permission for Prod and Test ? Where does Prod and Test comes from ?
Here is the template (some parts obfuscated or removed for security like environment vars)
AWSTemplateFormatVersion : 2010-09-09
Transform: AWS::Serverless-2016-10-31
Description: My API
Globals:
Function:
VpcConfig:
SecurityGroupIds:
- Fn::ImportValue: "ServerlessSecurityGroupId"
SubnetIds:
- "subnet-xxx"
- "subnet-xxx"
Resources:
LambdaExecutionRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
Service:
- lambda.amazonaws.com
Action:
- sts:AssumeRole
Policies:
- PolicyName: 'LambdaExecutionPolicy'
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- ec2:CreateNetworkInterface
- ec2:DescribeNetworkInterfaces
- ec2:DetachNetworkInterface
- ec2:DeleteNetworkInterface
Resource: "*"
RoleName: LambdaExecutionRole
MyApi:
Type: AWS::Serverless::Function
Properties:
FunctionName: "MyApi"
Handler: com.acme.api.ApiHandler
Runtime: java8
CodeUri: ./build/distributions/my-api.zip
Timeout: 60
MemorySize: 1024
Role: !GetAtt LambdaExecutionRole.Arn
Events:
Cors:
Type: Api
Properties:
Path: /{proxy+}
Method: options
# Auth
PostRegistrationsResource:
Type: Api
Properties:
Path: /auth/registrations
Method: post
PostConfirmationsResource:
Type: Api
Properties:
Path: /auth/confirmations
Method: post
PostRenewalsResource:
Type: Api
Properties:
Path: /auth/renewals
Method: post
PutUserResource:
Type: Api
Properties:
Path: /auth/users/{id}
Method: put
GetUserResource:
Type: Api
Properties:
Path: /auth/users/{id}
Method: get
GetUsersResource:
Type: Api
Properties:
Path: /auth/users
Method: get
GetAuthPingResource:
Type: Api
Properties:
Path: /auth/ping
Method: get
# Contacts
PostInvitationsResource:
Type: Api
Properties:
Path: /contacts/invitations
Method: post
PutInvitationsResource:
Type: Api
Properties:
Path: /contacts/invitations/{id}
Method: put
GetInvitationsMineResource:
Type: Api
Properties:
Path: /contacts/invitations/mine
Method: get
GetContactsMineResource:
Type: Api
Properties:
Path: /contacts/mine
Method: get
GetPossibleContactsMineResource:
Type: Api
Properties:
Path: /contacts/possibleContacts/mine
Method: get
PostPossibleInvitationsMineResource:
Type: Api
Properties:
Path: /contacts/possibleInvitations/mine
Method: post
GetContactsPingResource:
Type: Api
Properties:
Path: /contacts/ping
Method: get
# Admin
PostAdminLoginsResource:
Type: Api
Properties:
Path: /admin/logins
Method: post
PutAdminLoginsResource:
Type: Api
Properties:
Path: /admin/logins
Method: put
GetAdminsResource:
Type: Api
Properties:
Path: /admin/admins
Method: get
PostAdminsResource:
Type: Api
Properties:
Path: /admin/admins
Method: post
GetAdminResource:
Type: Api
Properties:
Path: /admin/admins/{id}
Method: get
PutAdminResource:
Type: Api
Properties:
Path: /admin/admins/{id}
Method: put
GetAdminPingResource:
Type: Api
Properties:
Path: /admin/ping
Method: get
# Providers
PostProvidersResource:
Type: Api
Properties:
Path: /providers/providers
Method: post
PutProvidersResource:
Type: Api
Properties:
Path: /providers/providers/{id}
Method: put
GetProvidersResource:
Type: Api
Properties:
Path: /providers/providers
Method: get
GetProviderResource:
Type: Api
Properties:
Path: /providers/providers/{id}
Method: get
# Offers
PostOffersResource:
Type: Api
Properties:
Path: /offers/offers
Method: post
PutOffersResource:
Type: Api
Properties:
Path: /offers/offers/{id}
Method: put
GetOffersResource:
Type: Api
Properties:
Path: /offers/offers
Method: get
GetOfferResource:
Type: Api
Properties:
Path: /offers/offers/{id}
Method: get
Contributor guide
Assessment
This issue has not been assessed yet.