I'm trying to deploy EC2 instance using cloudformation, It's giving the following error when i try to execute the stack.
Route table has a conflicting association with the gateway igw-0d7bbb47c8b4e8875 (Service: AmazonEC2; Status Code: 400; Error Code: RouteConflict; Request ID: 0ca161d0-b58d-4f95-a2f1-01038ccc4cae; Proxy: null)
Parameters:
InstanceType:
Type: "String"
Default: t2.micro
Image:
Type: "String"
Default: ami-0aab712d6363da7f9
Resources:
WebServer:
Type: AWS::EC2::Instance
Properties:
AvailabilityZone: ap-southeast-2a
KeyName: poweruser-keypair
InstanceType: !Ref InstanceType
ImageId: !Ref Image
SubnetId: !Ref SubNet
VPC:
Type: AWS::EC2::VPC
Properties:
CidrBlock: "10.0.0.0/16"
InstanceTenancy: default
SubNet:
Type: AWS::EC2::Subnet
Properties:
AvailabilityZone: ap-southeast-2a
MapPublicIpOnLaunch: true
CidrBlock: "10.0.0.0/24"
VpcId: !Ref VPC
InternetGateway:
Type: AWS::EC2::InternetGateway
IgwAttachment:
Type: AWS::EC2::VPCGatewayAttachment
Properties:
InternetGatewayId: !Ref InternetGateway
VpcId: !Ref VPC
RouteTable:
Type: AWS::EC2::RouteTable
Properties:
VpcId: !Ref VPC
RoutingToInternet:
Type: AWS::EC2::Route
DependsOn: IgwAttachment
Properties:
RouteTableId: !Ref RouteTable
DestinationCidrBlock: 0.0.0.0/0
GatewayId: !Ref InternetGateway
SubnetRouteTableAssociation:
Type: AWS::EC2::SubnetRouteTableAssociation
Properties:
RouteTableId: !Ref RouteTable
SubnetId: !Ref SubNet
SubnetNetworkAclAssociation:
Type: AWS::EC2::SubnetNetworkAclAssociation
Properties:
SubnetId:
Ref: SubNet
NetworkAclId:
Ref: NetworkACL
NetworkACL:
Type: AWS::EC2::NetworkAcl
Properties:
VpcId: !Ref VPC
NACLEntry:
Type: AWS::EC2::NetworkAclEntry
Properties:
CidrBlock: "10.0.0.0/16"
Egress: true
NetworkAclId: !Ref NetworkACL
Protocol: -1
RuleAction: "allow"
RuleNumber: 100
There is nothing wrong with your cloudformation template. This means that the code that you used in the question is not fully representative of your actual template that you use.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.