【发布时间】:2019-07-04 15:45:16
【问题描述】:
我是网络新手。我正在通过 Cloudformation 创建一个 VPC。在那,我必须创建 4 个子网。当我运行包含的模板时,我看到了这个错误: 模板错误:Fn::Select 无法选择索引 3 处不存在的值
但是,当我用 3 个子网创建它时,就可以了。
我的模板示例:
Parameters:
VpcBlock:
Type: String
Default: 192.168.0.0/16
Description: The CIDR range for the VPC. This should be a valid private (RFC 1918) CIDR range.
Subnet01Block:
Type: String
Default: 192.168.0.0/14
Description: CidrBlock for subnet 01 within the VPC
Subnet02Block:
Type: String
Default: 192.168.64.0/14
Description: CidrBlock for subnet 02 within the VPC
Subnet03Block:
Type: String
Default: 192.168.128.0/14
Description: CidrBlock for subnet 03 within the VPC
Subnet04Block:
Type: String
Default: 192.168.192.0/14
Description: CidrBlock for subnet 04 within the VPC
Resources:
Subnet01:
Type: AWS::EC2::Subnet
Metadata:
Comment: Subnet 01
Properties:
AvailabilityZone:
Fn::Select:
- '0'
- Fn::GetAZs:
Ref: AWS::Region
CidrBlock:
Ref: Subnet01Block
VpcId:
Ref: VPC
Tags:
- Key: Name
Value: !Sub "${AWS::StackName}-Services-Subnet01"
Subnet02:
Type: AWS::EC2::Subnet
Metadata:
Comment: Subnet 02
Properties:
AvailabilityZone:
Fn::Select:
- '1'
- Fn::GetAZs:
Ref: AWS::Region
CidrBlock:
Ref: Subnet02Block
VpcId:
Ref: VPC
Tags:
- Key: Name
Value: !Sub "${AWS::StackName}-Services-Subnet02"
Subnet03:
Type: AWS::EC2::Subnet
Metadata:
Comment: Subnet 03
Properties:
AvailabilityZone:
Fn::Select:
- '2'
- Fn::GetAZs:
Ref: AWS::Region
CidrBlock:
Ref: Subnet03Block
VpcId:
Ref: VPC
Tags:
- Key: Name
Value: !Sub "${AWS::StackName}-Services-Subnet03"
Subnet04:
Type: AWS::EC2::Subnet
Metadata:
Comment: Subnet 04
Properties:
AvailabilityZone:
Fn::Select:
- '3'
- Fn::GetAZs:
Ref: AWS::Region
CidrBlock:
Ref: Subnet04Block
VpcId:
Ref: VPC
Tags:
- Key: Name
Value: !Sub "${AWS::StackName}-Services-Subnet04"
我正在 us-west-2 区域部署此模板。 我在这里做错了吗?
【问题讨论】:
-
为什么要创建 4 个子网?
标签: amazon-web-services networking amazon-cloudformation amazon-vpc