AWS API网关默认限制输入/输出负载大小为10MB。但是,如果您的API负载超过API网关的限制,则API网关将拒绝该请求。要解决这个问题,可以通过在API Gateway设置中修改负载大小限制来扩展它。
以下是一个示例,将API Gateway负载限制增加到50MB:
Resources:
MyResource:
Type: AWS::ApiGateway::Resource
Properties:
ParentId: !GetAtt ApiGateway.RestApiRootResourceId
PathPart: myresource
MyMethod:
Type: AWS::ApiGateway::Method
Properties:
HttpMethod: POST
ResourceId: !Ref MyResource
RestApiId: !Ref ApiGateway
AuthorizationType: NONE
Integration:
Type: AWS_PROXY
IntegrationHttpMethod: POST
Uri: !Sub
- "https://${MyLambdaFunction.Arn}/"
- { MyLambdaFunction: !Ref MyLambdaFunction }
PassthroughBehavior: WHEN_NO_MATCH
ContentHandling: CONVERT_TO_BINARY
RequestParameters:
integration.request.header.Content-Type: "'application/json'"
RequestTemplates:
application/json: !Ref RequestTemplate
MethodResponses:
- StatusCode: 200
ResponseModels:
application/json: "Empty"
ApiGateway:
Type: AWS::ApiGateway::RestApi
Properties:
Name: "My API"
BinaryMediaTypes:
- 'application/octet-stream'
- 'image/jpeg'
EndpointConfiguration:
Types:
- "EDGE"
Policy: !Join
- "\n"
- - "Version: '2012-10-17'"
- "Statement:"
- " - Effect: Allow"
- " Principal: '*'"
- " Action:"
- " - execute-api:Invoke"
- " Resource:"
- " - !Sub 'arn:aws:execute-api:${AWS::Region}:${AWS::AccountId}:${ApiGateway}/test/POST/myresource/*'"
Stage:
Type: AWS::ApiGateway::Stage
Properties: