gpt4 book ai didi

parameters - Cloudformation - 将参数传递到二级堆栈

转载 作者:行者123 更新时间:2023-12-03 07:23:30 27 4
gpt4 key购买 nike

我正在尝试将一些参数传递给嵌套堆栈。

我当前的配置如下:

根模板:

Parameters:
SubnetIds:
Description: The array of Subnet IDs assigned to the lambdas
Type: List<AWS::EC2::Subnet::Id>
SecurityGroupIds:
Description: The array of Security Groups Assigned to the lambda functions
Type: List<AWS::EC2::SecurityGroup::Id>

Resources:
Myresource1:
Type: 'AWS::Serverless::Application'
Properties:
Location: 'resource1/template.yaml'
Parameters:
SubnetIds: !Join [',', !Ref SubnetIds]
SecurityGroupIds: !Join [',', !Ref SecurityGroupIds]

第一个嵌套堆栈:

Parameters:
SubnetIds:
Description: The array of Subnet IDs assigned to the lambdas
Type: List<AWS::EC2::Subnet::Id>
SecurityGroupIds:
Description: The array of Security Groups Assigned to the lambda functions
Type: List<AWS::EC2::SecurityGroup::Id>

Resources:
MySecondLevelResource:
Type: 'AWS::Serverless::Application'
Properties:
Location: 'app/template.yaml'
Parameters:
SubnetIds: !Ref SubnetIds
SecurityGroupIds: !Ref SecurityGroupIds

二级嵌套堆栈:

Parameters:
SubnetIds:
Description: The array of Subnet IDs assigned to the lambdas
Type: CommaDelimitedList
SecurityGroupIds:
Description: The array of Security Groups Assigned to the lambda functions
Type: CommaDelimitedList

使用此配置,当 AWS 尝试部署第一个嵌套堆栈时,我会收到错误,因为它需要字符串或字符串对象。我还尝试在第一级堆栈中使用 CommaDelimitedList 类型,但在第二级堆栈中仍然出现错误。到目前为止还没有运气。

有谁经历过这种情况或有任何解决办法吗?

最佳答案

首先,您的模板中有一个重大错误:

SubnetIds: !Join [',', !Ref SecurityGroupIds]

无论是否存在任何其他问题,使用 SecurityGroupIds 都会导致失败,因为 SecurityGroupIds 不是 SubnetIds

嵌套堆栈也是使用 AWS::CloudFormation::Stack 创建的它的语法与您正在使用的不同。因此,如果您实际上通过 AWS::CloudFormation::Stack 使用嵌套堆栈,则传递参数的方式是正确的

关于parameters - Cloudformation - 将参数传递到二级堆栈,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67524985/

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