【发布时间】:2020-04-14 02:35:20
【问题描述】:
我想将我的 SAM 应用程序拆分为多个部分。
我想在根堆栈中创建一个 API ( AWS::Serverless::Api )。
我正在我的子堆栈中创建 lambda 函数,我想在其中将 API 的引用从根堆栈提供给 API 事件。
这可行吗?没有找到从根栈访问API到子栈的好例子?
我尝试使用以下模板 -
parenttemplateapi:
Type: AWS::Serverless::Application
Properties:
Location:
ApplicationId: arn:aws:serverlessrepo:us-east-1:account_id:applications/parent-template
SemanticVersion: 1.0.0
HelloWorldFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: hello_world/
Handler: app.lambda_handler
Runtime: python2.7
Events:
HelloWorld:
Type: Api
Properties:
Method: get
Path: /hello
RestApiId: !GetAtt parenttemplateapi.Outputs.ServerlessGW-restApiId
当我尝试部署此模板时,出现以下错误 -
错误:无法为堆栈创建变更集:子模板,例如: Waiter ChangeSetCreateComplete failed: Waiter 遇到终端 故障状态 状态:FAILED。原因:转型 AWS::Serverless-2016-10-31 失败:内部转换失败。
任何指示/建议?
我指的是下面的链接-
这里可以使用来自根堆栈的 API Gateway Id (AWS::ApiGateway::RestApi) 吗?
https://dev.to/grahamcox82/building-a-larger-serverless-application-part-3-modular-monorepos-3mon
这可以使用无服务器框架实现吗?
【问题讨论】:
-
您在其他地方找到解决方案了吗?
-
这应该是可能的。但是,我想知道父模板的外观以及它是否包含名为 ServerlessGW-restApiId 的输出。
-
@MartinLöper 我想知道你和我是否曾经一起开发过 Visa 令牌服务钱包应用程序! :) 如果是这样,很高兴在 Digital Wild West 与您相遇!
-
@lopezdp 我不记得了。但是很高兴在数字狂野西部见到你:D
-
您找到解决方案了吗?通过使用 SAM,而不是无服务器框架?
标签: amazon-web-services amazon-cloudformation aws-api-gateway serverless-framework aws-sam