[英]Route53 Private Hosted Zone Parameterised List of VPCs
我正在嘗試為Route53私有托管區域創建雲形成模板,其中將與PHZ關聯的VPC和區域列表作為參數提供
VPCIds:
Type: List<AWS::EC2::VPC::Id>
Description: The Evertz VPC Id
Regions:
Type: CommaDelimitedList
Description: A list that containing the matching regions for the VPCs given
NumberOfVPC:
Type: Number
我已經設置了用於指定VPC數量的條件。
Conditions:
2VPC: !Or [
!Equals [!Ref NumberOfVPC, 2],
Condition: 3VPC,
Condition: 4VPC,
Condition: 5VPC,
Condition: 6VPC,
Condition: 7VPC,
Condition: 8VPC
]
3VPC: !Or [
!Equals [!Ref NumberOfVPC, 3],
Condition: 4VPC,
Condition: 5VPC,
Condition: 6VPC,
Condition: 7VPC,
Condition: 8VPC
]...
不幸的是,我無法創建HostedZoneVPC的列表
我希望在構建列表時使用這些條件來提供AWS :: NoValue
Route53PrivateHostedZone:
Type: "AWS::Route53::HostedZone"
Properties:
Name: !Ref ZoneName
HostedZoneConfig:
Comment: String
HostedZoneTags:
- Key: Name
Value: Hosted Zone
VPCs:
-
VPCId: !If [2VPC, !Ref "AWS::NoValue", !Select [0, !Ref VPCIds]]
VPCRegion: !If [2VPC, !Ref "AWS::NoValue", !Select [0, !Ref Regions]]
VPCs:
- VPCId: !If [2VPC, !Select [0, !Ref VPCIds], !Ref "AWS::NoValue"]
VPCRegion: !If [2VPC, !Select [0, !Ref Regions], !Ref "AWS::NoValue"]
- VPCId: !If [2VPC, !Select [1, !Ref VPCIds], !Ref "AWS::NoValue"]
VPCRegion: !If [2VPC, !Select [1, !Ref Regions], !Ref "AWS::NoValue"]
但是,這不起作用,並且無法創建托管區域。
Cloudformation中是否可以使用已創建的xVPC條件構造HostedZoneVPC列表?
我目前發現的解決方案是嵌套!If
並使用此處落入下一個VPC /區域列表,因為計數並不多。 還要更改條件,使它們不累積;
Conditions:
1VPC: !Equals [!Ref NumberOfVPC, 1]
2VPC: !Equals [!Ref NumberOfVPC, 2]
3VPC: !Equals [!Ref NumberOfVPC, 3]
4VPC: !Equals [!Ref NumberOfVPC, 4]
5VPC: !Equals [!Ref NumberOfVPC, 5]
6VPC: !Equals [!Ref NumberOfVPC, 6]
7VPC: !Equals [!Ref NumberOfVPC, 7]
8VPC: !Equals [!Ref NumberOfVPC, 8]
然后,VPCs屬性變為;
VPCs:
!If [1VPC,
[
{VPCId: !Select [0, !Ref VPCIds], VPCRegion: !Select [0, !Ref Regions]}
],
!If [2VPC,
[
{VPCId: !Select [0, !Ref VPCIds], VPCRegion: !Select [0, !Ref Regions]},
{VPCId: !Select [1, !Ref VPCIds], VPCRegion: !Select [1, !Ref Regions]}
],
!If [3VPC,
[
{VPCId: !Select [0, !Ref VPCIds], VPCRegion: !Select [0, !Ref Regions]},
{VPCId: !Select [1, !Ref VPCIds], VPCRegion: !Select [1, !Ref Regions]},
{VPCId: !Select [2, !Ref VPCIds], VPCRegion: !Select [2, !Ref Regions]}
],
!If [4VPC,
[
{VPCId: !Select [0, !Ref VPCIds], VPCRegion: !Select [0, !Ref Regions]},
{VPCId: !Select [1, !Ref VPCIds], VPCRegion: !Select [1, !Ref Regions]},
{VPCId: !Select [2, !Ref VPCIds], VPCRegion: !Select [2, !Ref Regions]},
{VPCId: !Select [3, !Ref VPCIds], VPCRegion: !Select [3, !Ref Regions]}
],
!If [5VPC,
[
{VPCId: !Select [0, !Ref VPCIds], VPCRegion: !Select [0, !Ref Regions]},
{VPCId: !Select [1, !Ref VPCIds], VPCRegion: !Select [1, !Ref Regions]},
{VPCId: !Select [2, !Ref VPCIds], VPCRegion: !Select [2, !Ref Regions]},
{VPCId: !Select [3, !Ref VPCIds], VPCRegion: !Select [3, !Ref Regions]},
{VPCId: !Select [4, !Ref VPCIds], VPCRegion: !Select [4, !Ref Regions]}
],
!If [6VPC,
[
{VPCId: !Select [0, !Ref VPCIds], VPCRegion: !Select [0, !Ref Regions]},
{VPCId: !Select [1, !Ref VPCIds], VPCRegion: !Select [1, !Ref Regions]},
{VPCId: !Select [2, !Ref VPCIds], VPCRegion: !Select [2, !Ref Regions]},
{VPCId: !Select [3, !Ref VPCIds], VPCRegion: !Select [3, !Ref Regions]},
{VPCId: !Select [4, !Ref VPCIds], VPCRegion: !Select [4, !Ref Regions]},
{VPCId: !Select [5, !Ref VPCIds], VPCRegion: !Select [5, !Ref Regions]}
],
!If [7VPC,
[
{VPCId: !Select [0, !Ref VPCIds], VPCRegion: !Select [0, !Ref Regions]},
{VPCId: !Select [1, !Ref VPCIds], VPCRegion: !Select [1, !Ref Regions]},
{VPCId: !Select [2, !Ref VPCIds], VPCRegion: !Select [2, !Ref Regions]},
{VPCId: !Select [3, !Ref VPCIds], VPCRegion: !Select [3, !Ref Regions]},
{VPCId: !Select [4, !Ref VPCIds], VPCRegion: !Select [4, !Ref Regions]},
{VPCId: !Select [5, !Ref VPCIds], VPCRegion: !Select [5, !Ref Regions]},
{VPCId: !Select [6, !Ref VPCIds], VPCRegion: !Select [6, !Ref Regions]}
],
!If [8VPC,
[
{VPCId: !Select [0, !Ref VPCIds], VPCRegion: !Select [0, !Ref Regions]},
{VPCId: !Select [1, !Ref VPCIds], VPCRegion: !Select [1, !Ref Regions]},
{VPCId: !Select [2, !Ref VPCIds], VPCRegion: !Select [2, !Ref Regions]},
{VPCId: !Select [3, !Ref VPCIds], VPCRegion: !Select [3, !Ref Regions]},
{VPCId: !Select [4, !Ref VPCIds], VPCRegion: !Select [4, !Ref Regions]},
{VPCId: !Select [5, !Ref VPCIds], VPCRegion: !Select [5, !Ref Regions]},
{VPCId: !Select [6, !Ref VPCIds], VPCRegion: !Select [6, !Ref Regions]},
{VPCId: !Select [7, !Ref VPCIds], VPCRegion: !Select [7, !Ref Regions]}
],
!Ref "AWS::NoValue"
]
]
]
]
]
]
]
]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.