Complete the code to create an Internet Gateway resource in AWS CloudFormation.
Resources:
MyInternetGateway:
Type: [1]The Internet Gateway resource type in AWS CloudFormation is AWS::EC2::InternetGateway. This creates an Internet Gateway for public access.
Complete the code to attach the Internet Gateway to a VPC.
Resources:
AttachGateway:
Type: AWS::EC2::VPCGatewayAttachment
Properties:
VpcId: [1]
InternetGatewayId: !Ref MyInternetGatewayThe VpcId property must reference the VPC resource ID to attach the Internet Gateway correctly.
Fix the error in the route table to enable public internet access through the Internet Gateway.
Resources:
PublicRoute:
Type: AWS::EC2::Route
Properties:
RouteTableId: !Ref PublicRouteTable
DestinationCidrBlock: [1]
GatewayId: !Ref MyInternetGatewayThe destination CIDR block 0.0.0.0/0 routes all internet traffic through the Internet Gateway, enabling public access.
Fill both blanks to define a public subnet with a route to the Internet Gateway.
Resources:
PublicSubnet:
Type: AWS::EC2::Subnet
Properties:
VpcId: [1]
CidrBlock: 10.0.1.0/24
PublicRoute:
Type: AWS::EC2::Route
Properties:
RouteTableId: !Ref PublicRouteTable
DestinationCidrBlock: [2]
GatewayId: !Ref MyInternetGatewayThe subnet must belong to the VPC (MyVPC), and the route destination for internet traffic is 0.0.0.0/0.
Fill all three blanks to create an Internet Gateway, attach it to a VPC, and add a route for public access.
Resources:
InternetGateway:
Type: [1]
AttachGateway:
Type: AWS::EC2::VPCGatewayAttachment
Properties:
VpcId: [2]
InternetGatewayId: !Ref InternetGateway
PublicRoute:
Type: AWS::EC2::Route
Properties:
RouteTableId: !Ref PublicRouteTable
DestinationCidrBlock: [3]
GatewayId: !Ref InternetGatewayThe Internet Gateway resource type is AWS::EC2::InternetGateway. It must be attached to the VPC MyVPC. The route destination for internet traffic is 0.0.0.0/0.