gpt4 book ai didi

aws-cloudformation - AWS::Serverless::HttpApi OpenAPI 定义与 http 集成

转载 作者:行者123 更新时间:2023-12-03 07:23:16 26 4
gpt4 key购买 nike

我定义了以下AWS::Serverless::HttpApi:

MyApi:
Type: AWS::Serverless::HttpApi
Properties:
CorsConfiguration:
AllowOrigins:
- http://localhost:3000
- https://localhost:3000
- https://my.site
Domain:
CertificateArn: !Ref MahCert
DomainName: api.my.site
EndpointConfiguration: REGIONAL
Route53:
# Very similar to one of the record sets in the R53 record set groups
DistributionDomainName: !GetAtt CloudFrontCDN.DomainName
HostedZoneId: !Ref MyHostedZone
IpV6: true
StageName: Prod
DefinitionBody:
openapi: "3.0.1"
info:
title: api.my.site
paths:
/steam/hours:
get:
responses:
"200":
description: "200 response"
headers:
Access-Control-Allow-Origin:
schema:
type: "string"
content: { }
x-amazon-apigateway-integration:
type: "http"
httpMethod: "GET"
uri: "https://example.com"
responses:
default:
statusCode: "200"
responseParameters:
method.response.header.Access-Control-Allow-Origin: "'*'"
passthroughBehavior: "when_no_match"

AccessLogSettings:
DestinationArn: !GetAtt CloudWatchLogGroup.Arn
Format: '{ "$context.requestId": { "error": { "message": "$context.error.message", "messageString": "$context.error.messageString", "responseType": "$context.error.responseType" }, "integrationError": { "message": "$context.integrationErrorMessage", "error": "$context.integration.error", "status": "$context.integration.status" }}}'

此 OpenAPI 定义应该定义一个具有 HTTP 集成的路由,该路由将请求代理到 https://example.com。实际上,我从手动构建的 REST API 中导出了此 OpenAPI 规范。我没有从 CloudFormation 收到任何有关缺少属性的问题。

当我尝试访问该路由时,收到 404。原因是该路由实际上没有附加任何集成: enter image description here

为什么 CloudFormation 不在这里应用 http 集成?

最佳答案

HttpApi AWS Gateway 上不支持 HTTP 自定义集成。它确实支持 HTTP_PROXY 集成。 Here是文档。 Rest APIs支持 HTTPHTTP_PROXY 集成。

要添加 HTTP_PROXY 集成,以下是 /steam/hours GET 操作的模板外观。

paths:
/steam/hours:
get:
x-amazon-apigateway-integration:
type: "http_proxy"
httpMethod: "GET"
uri: "https://example.com"
payloadFormatVersion: "1.0"

关于aws-cloudformation - AWS::Serverless::HttpApi OpenAPI 定义与 http 集成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68630152/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com