我正在创建一个Cloudformation模板,我对一些概念感到困惑。首先,是否需要在RouteTable中每个需要定义的路由中拖放一个路由对象?
或者,我可以在同一条线路上添加更多的DestinationCidrBlock吗?
AWS::EC2::Route
PrivateRoute:
Type: 'AWS::EC2::Route'
Properties:
RouteTableId: !Ref PrivateRouteTable
InstanceId: !Ref EC2PublicServer
DestinationCidrBlock: 0.0.0.0/0发布于 2019-06-08 22:17:01
不能在DestinationCidrBlock属性中放置多个值。根据文献资料,它只接受一个字符串。
不幸的是,AWS::EC2::RouteTable资源本身不能包括路由列表。因此,您需要添加尽可能多的AWS::EC2::路由资源,就像您需要包含的流程一样。
可能的解决方案是使用CloudFormation变换宏从列表中生成多个路由资源。我不知道这是否可能。
更新:
我可以用宏来做
我编写了这个模板,它工作得很好,创建了指向同一个Internet网关的几条路由
AWSTemplateFormatVersion: "2010-09-09"
Transform: Explode
Parameters:
VpcId:
Type: AWS::EC2::VPC::Id
Description: VPC ID of the VPC in which to create the route table
InternetGateway:
Type: String
Description: Internet gateway id
Mappings:
CidrMap:
Destination1:
Cidr: 180.1.2.0/24
Destination2:
Cidr: 200.1.1.0/24
Resources:
RouteTable:
Type: AWS::EC2::RouteTable
Properties:
VpcId: !Ref VpcId
Route:
Type: AWS::EC2::Route
ExplodeMap: CidrMap
Properties:
DestinationCidrBlock: "!Explode Cidr"
GatewayId: !Ref InternetGateway
RouteTableId: !Ref RouteTablehttps://stackoverflow.com/questions/56507520
复制相似问题