AWS Cloudformation conditions

0

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
질문됨 일 년 전205회 조회
1개 답변
0

Hi, Look at https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-conditions.html#intrinsic-function-reference-conditions-if

"Fn::If": [condition_name, value_if_true, value_if_false]

You have to create second If in the value_if_false of your current if.

profile pictureAWS
전문가
답변함 일 년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠