以下是一个使用AWS CloudFormation创建路由表的示例模板:
AWSTemplateFormatVersion: '2010-09-09'
Resources:
MyVPC:
Type: AWS::EC2::VPC
Properties:
CidrBlock: 10.0.0.0/16
MySubnet:
Type: AWS::EC2::Subnet
Properties:
VpcId: !Ref MyVPC
CidrBlock: 10.0.0.0/24
MyInternetGateway:
Type: AWS::EC2::InternetGateway
MyGatewayAttachment:
Type: AWS::EC2::VPCGatewayAttachment
Properties:
VpcId: !Ref MyVPC
InternetGatewayId: !Ref MyInternetGateway
MyRouteTable:
Type: AWS::EC2::RouteTable
Properties:
VpcId: !Ref MyVPC
MyRoute:
Type: AWS::EC2::Route
DependsOn: MyGatewayAttachment
Properties:
RouteTableId: !Ref MyRouteTable
DestinationCidrBlock: 0.0.0.0/0
GatewayId: !Ref MyInternetGateway
MySubnetRouteTableAssociation:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
SubnetId: !Ref MySubnet
RouteTableId: !Ref MyRouteTable
这个模板定义了一个VPC、一个子网、一个互联网网关、一个路由表和一个路由。它将路由表与子网关联,并将默认路由指向互联网网关。
要使用此模板,您可以使用AWS CloudFormation控制台或AWS CLI来部署堆栈。
上一篇:AWS云搜索可扩展吗?