AWSTemplateFormatVersion: '2010-09-09' Description: > **WARNING** This template creates VPC, Subnets, NATGateway and related resources. You will be billed for the AWS resources used if you create a stack from this template. Parameters: VPCCidr: Type: String Default: '10.0.0.0/16' PublicSubnetCidr: Type: String Default: '10.0.0.0/24' PrivateSubnetFirstCidr: Type: String Default: '10.0.1.0/24' PrivateSubnetSecondCidr: Type: String Default: '10.0.2.0/24' PrivateSubnetThirdCidr: Type: String Default: '10.0.3.0/24' Resources: VPC: Type: AWS::EC2::VPC Properties: EnableDnsSupport: true EnableDnsHostnames: true CidrBlock: !Ref 'VPCCidr' Tags: - Key: 'Name' Value: 'MSKVPC' PublicSubnetOne: Type: AWS::EC2::Subnet Properties: AvailabilityZone: Fn::Select: - 0 - Fn::GetAZs: {Ref: 'AWS::Region'} VpcId: !Ref 'VPC' CidrBlock: !Ref 'PublicSubnetCidr' MapPublicIpOnLaunch: true Tags: - Key: 'Name' Value: 'PublicSubnet' PrivateSubnetMSKOne: Type: AWS::EC2::Subnet Properties: AvailabilityZone: Fn::Select: - 0 - Fn::GetAZs: {Ref: 'AWS::Region'} VpcId: !Ref 'VPC' CidrBlock: !Ref 'PrivateSubnetFirstCidr' MapPublicIpOnLaunch: false Tags: - Key: 'Name' Value: 'PrivateSubnetMSKOne' PrivateSubnetMSKTwo: Type: AWS::EC2::Subnet Properties: AvailabilityZone: Fn::Select: - 1 - Fn::GetAZs: {Ref: 'AWS::Region'} VpcId: !Ref 'VPC' CidrBlock: !Ref 'PrivateSubnetSecondCidr' MapPublicIpOnLaunch: false Tags: - Key: 'Name' Value: 'PrivateSubnetMSKTwo' PrivateSubnetMSKThree: Type: AWS::EC2::Subnet Properties: AvailabilityZone: Fn::Select: - 2 - Fn::GetAZs: {Ref: 'AWS::Region'} VpcId: !Ref 'VPC' CidrBlock: !Ref 'PrivateSubnetThirdCidr' MapPublicIpOnLaunch: false Tags: - Key: 'Name' Value: 'PrivateSubnetMSKThree' InternetGateway: Type: AWS::EC2::InternetGateway GatewayAttachement: Type: AWS::EC2::VPCGatewayAttachment Properties: VpcId: !Ref 'VPC' InternetGatewayId: !Ref 'InternetGateway' NATEIP: Type: AWS::EC2::EIP DependsOn: GatewayAttachement Properties: Domain: vpc NATGateway: Type: AWS::EC2::NatGateway Properties: AllocationId: !GetAtt NATEIP.AllocationId SubnetId: !Ref 'PublicSubnetOne' Tags: - Key: 'Name' Value: 'ConfluentKafkaNATGateway' PublicRouteTable: Type: AWS::EC2::RouteTable Properties: VpcId: !Ref 'VPC' PublicRoute: Type: AWS::EC2::Route DependsOn: GatewayAttachement Properties: RouteTableId: !Ref 'PublicRouteTable' DestinationCidrBlock: '0.0.0.0/0' GatewayId: !Ref 'InternetGateway' PublicSubnetOneRouteTableAssociation: Type: AWS::EC2::SubnetRouteTableAssociation Properties: SubnetId: !Ref 'PublicSubnetOne' RouteTableId: !Ref PublicRouteTable PrivateRouteTable: Type: AWS::EC2::RouteTable Properties: VpcId: !Ref 'VPC' PrivateRoute: Type: AWS::EC2::Route Properties: RouteTableId: !Ref 'PrivateRouteTable' DestinationCidrBlock: '0.0.0.0/0' NatGatewayId: !Ref 'NATGateway' PrivateSubnetMSKOneRouteTableAssociation: Type: AWS::EC2::SubnetRouteTableAssociation Properties: RouteTableId: !Ref 'PrivateRouteTable' SubnetId: !Ref 'PrivateSubnetMSKOne' PrivateSubnetMSKTwoRouteTableAssociation: Type: AWS::EC2::SubnetRouteTableAssociation Properties: RouteTableId: !Ref 'PrivateRouteTable' SubnetId: !Ref 'PrivateSubnetMSKTwo' PrivateSubnetMSKThreeRouteTableAssociation: Type: AWS::EC2::SubnetRouteTableAssociation Properties: RouteTableId: !Ref 'PrivateRouteTable' SubnetId: !Ref 'PrivateSubnetMSKThree' Outputs: VPCId: Description: The ID of the VPC created Value: !Ref 'VPC' Export: Name: !Sub "${AWS::StackName}-VPCID" PublicSubnetCidr: Description: Public subnet CIDR address Value: !Ref 'PublicSubnetCidr' Export: Name: !Sub "${AWS::StackName}-PublicSubnetCidr" PublicSubnetOne: Description: The ID of the public subnet created Value: !Ref 'PublicSubnetOne' Export: Name: !Sub "${AWS::StackName}-PublicSubnetOne" PrivateSubnetMSKOne: Description: The ID of private subnet one created Value: !Ref 'PrivateSubnetMSKOne' Export: Name: !Sub "${AWS::StackName}-PrivateSubnetMSKOne" PrivateSubnetMSKTwo: Description: The ID of private subnet two created Value: !Ref 'PrivateSubnetMSKTwo' Export: Name: !Sub "${AWS::StackName}-PrivateSubnetMSKTwo" PrivateSubnetMSKThree: Description: The ID of private subnet three created Value: !Ref 'PrivateSubnetMSKThree' Export: Name: !Sub "${AWS::StackName}-PrivateSubnetMSKThree" VPCStackName: Description: The name of the VPC Stack Value: !Ref 'AWS::StackName' Export: Name: !Sub "${AWS::StackName}-VPCStackName"