I would like to have an IF-ELSE statement to assign subnets.
If 1 AZ is being used, assign privatesubnet1 to subnets
If 2 AZ is being used, assign privatesubnet1 and privatesubnet2 to subnets
If 3 AZ is being used, assign privatesubnet1, privatesubnet2 and privatesubnet3 to subnets
The IF function handles 1 and 2 AZ well, but I don’t know how to handle 3 AZ
Suggestions are welcome.
Conditions:
SingleZone:
!Equals [!Ref NumberOfZones, 1]
TwoZones:
!Equals [!Ref NumberOfZones, 2]
ThreeZones:
!Equals [!Ref NumberOfZones, 3]
Resources:
Properties:
Subnets:
- !If [TwoZones, !Join [',', [!Ref PrivateSubnet1, !Ref PrivateSubnet2]], !Ref PrivateSubnet1]
#How to handle ThreeZones