parameters - Cloudformation - 将参数传递到二级堆栈
问题描述
我正在尝试将一些参数传递给嵌套堆栈。
我目前的配置如下:
根模板:
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
将导致失败 as SecurityGroupIds
are not SubnetIds
,不管任何其他问题。
嵌套堆栈也是使用AWS::CloudFormation::Stack创建的,它的语法与您使用的不同。因此,如果您实际上是通过AWS::CloudFormation::Stack
.
推荐阅读
- typescript - 为什么使用 cordova google-plus 插件会弹出两次“确认您的选择”?
- python - 快速替换字符串中的字符并检查子字符串是否为回文
- apache-spark - Cassandra + Spark 执行器超融合
- android - 如何从 Firestore 服务器获取时间戳,而无需担心设备时钟与 Firestore 不同步的情况
- c++ - Clang 工具(clang-tidy、iwyu 等)的单遍运行以及编译?
- matlab - fmincon:优化 MPC 的问题
- reactjs - 为什么我需要在 `useEffect` 中定义事件处理程序 `handleStatusChange`?
- r - 在 levelplot 中每种颜色的中间放置刻度
- java - 无法使用 geoTools 获取 FeaturesCollection 中的内容
- flutter - 删除 Firebase 存储中的所有文件