gpt4 book ai didi

amazon-web-services - 使用 Nested Stack 将 API 网关错误与其他堆栈上的 use 分开

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

我在尝试部署嵌套堆栈时遇到错误,其中一个堆栈有 APIGateway 设置,而其他堆栈有 lambdas 服务

主模板

Resources:
SubStackAPIDev:
Type: 'AWS::CloudFormation::Stack'
Properties:
TemplateURL: https://c....
TimeoutInMinutes: 5

SubStacklambdaA:
Type: 'AWS::CloudFormation::Stack'
Properties:
TemplateURL: https://c....
TimeoutInMinutes: 5
Parameters:
APIDev: !Ref APIGateway
.....

SubStackAPIDev

AWSTemplateFormatVersion: "2010-09-09"

Transform: AWS::Serverless-2016-10-31

....

Outputs:

APIGateway:
Description: "API Gateway Reference"
Value: !Ref APIDev
Export:
Name: !Join [":", [!Ref "AWS::StackName", "APIDev"]]

SubStacklambdaA


AWSTemplateFormatVersion: "2010-09-09"
Transform: AWS::Serverless-2016-10-31
Parameters:
SecretsManagerName:
....
APIDev:
Type: string

Resources:
LambdaFunctionDev:
Type: AWS::Serverless::Function
Properties:
...
Events:
ApiEvent:
Type: Api
Properties:
Path: ....
Method: POST
RestApiId: !Ref APIDev

当我执行 sam package 命令时,控制台返回下一个错误:

sam deploy --force-upload --template-file maintemplate-packaged.yaml --stack-name $STACK_NAME_DEV --region $AWS_REGION --capabilities CAPABILITY_AUTO_EXPAND CAPABILITY_IAM

Initiating deployment
=====================
Error: Failed to create changeset for the stack: B2bChannels-dev, An error occurred (ValidationError) when calling the CreateChangeSet operation: Template format error: Unresolved resource dependencies [APIGateway] in the Resources block of the template

如何将 ApGateWay 资源导出到主模板,以发送另一个堆栈?

最佳答案

要引用嵌套堆栈的输出,您应该使用 GetAtt:

  SubStacklambdaA:
Type: 'AWS::CloudFormation::Stack'
Properties:
TemplateURL: https://c....
TimeoutInMinutes: 5
Parameters:
APIDev: !GetAtt SubStackAPIDev.Outputs.APIGateway

关于amazon-web-services - 使用 Nested Stack 将 API 网关错误与其他堆栈上的 use 分开,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70371649/

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