gpt4 book ai didi

aws-cloudformation - AWS SAM - 如何为 FunctionAlias 创建 API 事件?

转载 作者:行者123 更新时间:2023-12-03 07:19:50 25 4
gpt4 key购买 nike

我的 SAM 模板当前使用 Lambda 函数通过 API 网关提供信息。但是,我希望 API 网关指向一个别名。

如何使用 SAM 做到这一点?

LambdaFunction:
Type: 'AWS::Serverless::Function'
Properties:
Runtime: nodejs14.x
Handler: index.handler
CodeUri: ./software
MemorySize: 128
FunctionName: Name
Timeout: 5
Policies:
- AmazonDynamoDBReadOnlyAccess
Events:
MyApiResource:
Type: Api
Properties:
Path: /path
Method: get
RestApiId: !Ref ApiGatewayApi
FunctionAlias:
Type: AWS::Lambda::Alias
Properties:
FunctionName: !Ref LambdaFunction
FunctionVersion: !GetAtt FunctionVersion.Version
Name: prod

我尝试将事件剪切并粘贴到别名,但没有成功。

最佳答案

AutoPublishAlias 属性添加到 lambda 函数时,API 网关将在创建集成时使用该别名(通过使用 FQ Lambda ARN)

因此您只需将以下内容添加到函数中:

AutoPublishAlias: prod

链接 here

关于aws-cloudformation - AWS SAM - 如何为 FunctionAlias 创建 API 事件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70756595/

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