requires SubnetIds as one of the parameters.
If you provide subnets ids as part of the parameters to your template, you can use parameter with List<AWS::EC2::Subnet::Id>
type:
Parameters:
Subnets:
Type: List<AWS::EC2::Subnet::Id>
Then in the rest of the code, could refer to entire list or individual subnets as follows:
!Ref Subnets # entire list
!Select [0, !Ref Subnets] # first subnet provided in the list
If you create subnets in your template:
Resources:
MySubnet1:
Type: AWS::EC2::Subnet
Properties:
# properties
MySubnet2:
Type: AWS::EC2::Subnet
Properties:
# properties other subnet
Then to refer to their ids, you can use Ref which returns subnet id:
!Ref MySubnet1
!Ref MySubnet2
However, if you want to use existing subnets, defined outside of CloudFormation, in your templates, you can import existing subnets into your stack:
But this is not automatic process. You have to manually modify your template first for that to work.