I am trying to launch a stack by passing a list of subnet IDs and VPC IDs as parameter to a nested stack. However the stack fails with an error as below. Can anybody please suggest how to pass a list in nested stack. Parameters section of parent stack Resources section of parent stack Error
1
votes
2 Answers
2
votes
Agree with @Alex Harvey. What is the Server-Stack
expecting? A list of subnet-ids or single subnet-id?
Looking at your parent stack your PublicSubnetIds
& PrivateSubnetIds
are declared as lists. If you meant to pass a list to your Server-Stack
, you have to declare them as type List<AWS::EC2::Subnet::Id>
in Parameters
section of your Server-Stack
1
votes
Your code is passing Ref! PublicSubnetIds
of type List<AWS::EC2::Subnet::Id>
into a field that apparently expects data of type AWS::EC2::Subnet::Id
.
To select the nth element of a list use the intrinsic function Fn::Select, i.e.
SubnetId1: !Select [0, !Ref PublicSubnetIds]
SubnetId2: !Select [1, !Ref PublicSubnetIds]