gpt4 book ai didi

amazon-web-services - AWS SAM 模板:通过 AWS::Serverless::Api 创建代理

转载 作者:行者123 更新时间:2023-12-05 06:21:42 26 4
gpt4 key购买 nike

我正在寻找一种通过 AWS SAM (AWS::Serverless::Api) 定义简单 AWS ApiGateway 代理的方法

例如

foo.com/unitrans -> 访问 AWS S3 中的文件并返回其内容。

enter image description here

有办法吗?

最佳答案

@Alex 谢谢你的帖子,它很有帮助。这是我最终做的。

    AMASApiGateway:
Type: "AWS::ApiGateway::RestApi"
Properties:
Name: "amas-api"
Description: "Aggie Mobile Api Service : API"

AMASApiResource:
Type: 'AWS::ApiGateway::Resource'
Properties:
ParentId: !GetAtt AMASApiGateway.RootResourceId
RestApiId: !Ref AMASApiGateway
PathPart: 'unitrans'

AMASApiProxyMethod:
Type: 'AWS::ApiGateway::Method'
Properties:
HttpMethod: GET
ResourceId: !Ref AMASApiResource
RestApiId: !Ref AMASApiGateway
AuthorizationType: NONE
RequestParameters:
method.request.path.proxy: true
Integration:
CacheKeyParameters:
- 'method.request.path.proxy'
RequestParameters:
integration.request.path.proxy: 'method.request.path.proxy'
IntegrationHttpMethod: GET
Type: HTTP_PROXY
Uri: !Sub '<S3 hosted JSON file URI>'
PassthroughBehavior: WHEN_NO_MATCH
IntegrationResponses:
- StatusCode: 200

AMASApiGatewayDeployment:
Type: "AWS::ApiGateway::Deployment"
DependsOn:
- "AMASApiProxyMethod"
Properties:
RestApiId: !Ref AMASApiGateway
StageName: !Ref Environment

关于amazon-web-services - AWS SAM 模板:通过 AWS::Serverless::Api 创建代理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59655602/

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