作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的 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/
我是一名优秀的程序员,十分优秀!