1
votes

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 Parent stack Resources section of parent stack Parent stack resources Error Error Child template

2
You would need to also show the relevant sections of your code.Alex Harvey
I have added Parameter section and Resources section of Parent Template. Please check.Madhur Asati

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]