在CloudFormation中使用导出和导入功能时遇到了问题。当我尝试导入实际上是列表(数组)的值时,收到以下错误消息“与类型{Array}不匹配”。
vpc.yaml(摘要)
PrivateSubnets:
Description: A list of the private subnets
Value: !Join [",", [!Ref PrivateSubnetOne, !Ref PrivateSubnetTwo]]
Export:
Name: !Join ["-", [!Ref "Environment", "PrivateSubnets"] ]
pipeline.yaml(摘要)
Subnets:
Fn::ImportValue: !Sub "${Environment}-PrivateSubnets"
错误消息:
Property validation failure: [Value of property {/VpcConfig/Subnets} does not match type {Array}
答案 0 :(得分:1)
此代码解决了该问题;
Subnets: !Split
- ","
- Fn::ImportValue:
!Sub "${Environment}-PrivateSubnets"
答案 1 :(得分:0)
拆分 + 选择应该可以工作,因为您将能够拆分数组并单独选择每个项目,例如:
"/*"
...从导入的子网 ID 数组中选择第二个元素。