我是云形成的新手。我尝试使用云形成创建vpc,子网及其路由表。但无法创建。任何人都可以帮助我解决此问题。我的yaml文件如下:
myvpc:
Type: AWS::EC2::VPC
Properties:
CidrBlock: 10.0.0.0/16
EnableDnsSupport: true
EnableDnsHostnames: true
InstanceTenancy: default
Tags:
- Name: gccvpc
myinternetgateway:
Type: AWS::EC2::InternetGateway
Properties:
Tags:
- Name: gccgt
mygatewayattach:
Type: AWS::EC2::VPCGatewayAttachment
Properties:
InternetGatewayId: !Ref myinternetgateway
VpcId: !Ref myvpc
mysubnet1:
Type: AWS::EC2::Subnet
Properties:
AvailabilityZone: us-east-1a
VpcId: !Ref myvpc
CidrBlock: 10.0.1.0/24
MapPublicIpOnLaunch: true
Routetable:
Type: AWS::EC2::RouteTable
Properties:
VpcId: !Ref myvpc
Route:
Type: AWS::EC2::Route
DependsOn: myinternetgateway
Properties:
DestinationCidrBlock: 0.0.0.0/0
GatewayId: !Ref myinternetgateway
RouteTableId: !Ref Routetable
SubnetARouteTableAssociation:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
RouteTableId: !Ref Routetable
SubnetId: !Ref mysubnet1
答案 0 :(得分:2)
您缺少资源条件,并且标签属性不正确。请下次发布错误,您可以在CloudFormation控制台的“事件”标签上找到该错误。
Resources:
myvpc:
Type: "AWS::EC2::VPC"
Properties:
CidrBlock: "10.0.0.0/16"
EnableDnsSupport: "true"
EnableDnsHostnames: "true"
InstanceTenancy: "default"
Tags:
- Key: "Name"
Value: "gccvpc"
myinternetgateway:
Type: "AWS::EC2::InternetGateway"
Properties:
Tags:
- Key: "Name"
Value: "gccvpc"
mygatewayattach:
Type: "AWS::EC2::VPCGatewayAttachment"
Properties:
InternetGatewayId: !Ref "myinternetgateway"
VpcId: !Ref "myvpc"
mysubnet1:
Type: "AWS::EC2::Subnet"
Properties:
AvailabilityZone: "us-east-1a"
VpcId: !Ref "myvpc"
CidrBlock: "10.0.1.0/24"
MapPublicIpOnLaunch: "true"
Routetable:
Type: "AWS::EC2::RouteTable"
Properties:
VpcId: !Ref "myvpc"
Route:
Type: "AWS::EC2::Route"
DependsOn: "myinternetgateway"
Properties:
DestinationCidrBlock: "0.0.0.0/0"
GatewayId: !Ref "myinternetgateway"
RouteTableId: !Ref "Routetable"
SubnetARouteTableAssociation:
Type: "AWS::EC2::SubnetRouteTableAssociation"
Properties:
RouteTableId: !Ref "Routetable"
SubnetId: !Ref "mysubnet1"