Amazon web services 使用CloudFront在AWS API上启用POST
我按照本教程()构建了一个基本API 然后,在AWS API网关的Amazon web services 使用CloudFront在AWS API上启用POST,amazon-web-services,aws-lambda,amazon-cloudformation,amazon-cloudfront,Amazon Web Services,Aws Lambda,Amazon Cloudformation,Amazon Cloudfront,我按照本教程()构建了一个基本API 然后,在AWS API网关的lambda管道堆栈上,我添加了一个自定义域(例如API.example.com),它指向CloudFront发行版 当我尝试将模板更改为使用POST请求而不是GET时,收到一个错误: This distribution is not configured to allow the HTTP request method that was used for this request. The distribution suppor
lambda管道堆栈上,我添加了一个自定义域(例如API.example.com),它指向CloudFront发行版
当我尝试将模板更改为使用POST
请求而不是GET
时,收到一个错误:
This distribution is not configured to allow the HTTP request method that was used for this request.
The distribution supports only cachable requests.
但是,当我进入CloudFront发行版尝试启用POST
时,该发行版是不可访问的。如何为这种类型的API启用POST
以下是我的模板供参考:
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: Shows time
Resources:
TimeFunction:
Type: AWS::Serverless::Function
Properties:
Handler: index.handler
Runtime: nodejs10
CodeUri: ./
Events:
MyTimeApi:
Type: Api
Properties:
Path: /time
Method: POST
您需要在CloudFront上允许POST,因为默认情况下只允许GET、HEAD
Type: AWS::CloudFront::Distribution
Properties:
DistributionConfig:
...
HttpVersion: http2
DefaultCacheBehavior:
...
AllowedMethods: [DELETE, GET, HEAD, OPTIONS, PATCH, POST, PUT]
您需要允许在CloudFront上发布,因为默认情况下只允许GET、HEAD
Type: AWS::CloudFront::Distribution
Properties:
DistributionConfig:
...
HttpVersion: http2
DefaultCacheBehavior:
...
AllowedMethods: [DELETE, GET, HEAD, OPTIONS, PATCH, POST, PUT]
您的发行版的配置是什么?您是否有可包含该资源的cloudformation模板?您的发行版的配置是什么?您是否有可包含该资源的cloudformation模板?