【发布时间】:2020-06-29 13:34:07
【问题描述】:
我已按照本教程 (https://docs.aws.amazon.com/lambda/latest/dg/build-pipeline.html) 构建了一个基本 API。
然后,在 lambda-pipeline-stack 的 AWS API 网关上,我添加了一个指向 CloudFront 分配的自定义域(例如 api.example.com)。
当我尝试将模板更改为使用 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
【问题讨论】:
-
您的 Distribution 的配置是什么,您有可以包含该资源的 cloudformation 模板吗?
标签: amazon-web-services aws-lambda amazon-cloudformation amazon-cloudfront