Parameters: KeyName: Description: input EC2 Keyname Type: 'AWS::EC2::KeyPair::KeyName' Resources: TestVPC: Type: 'AWS::EC2::VPC' Properties: CidrBlock: 10.5.0.0/16 InstanceTenancy: default Tags: - Key: Name Value: TestVPC TestIGW: Type: 'AWS::EC2::InternetGateway' Properties: Tags: - Key: Name Value: TestIGW PublicRoute: Type: 'AWS::EC2::RouteTable' Properties: VpcId: Ref: TestVPC Tags: - Key: Name Value: PublicRoute Route: Type: 'AWS::EC2::Route' Properties: RouteTableId: Ref: PublicRoute DestinationCidrBlock: 0.0.0.0/0 GatewayId: Ref: TestIGW AttachIGW: Type: 'AWS::EC2::VPCGatewayAttachment' Properties: InternetGatewayId: Ref: TestIGW VpcId: Ref: TestVPC PublicSubnet: Type: 'AWS::EC2::Subnet' Properties: AvailabilityZone: us-west-2a CidrBlock: 10.5.1.0/24 VpcId: Ref: TestVPC Tags: - Key: Name Value: PublicSubnet PublicSubnetRouteTableAssociation: Type: 'AWS::EC2::SubnetRouteTableAssociation' Properties: SubnetId: Ref: PublicSubnet RouteTableId: Ref: PublicRoute PublicSG: Type: 'AWS::EC2::SecurityGroup' Properties: VpcId: Ref: TestVPC GroupDescription: TestIGW SecurityGroupIngress: - IpProtocol: tcp FromPort: '22' ToPort: '22' CidrIp: 0.0.0.0/0 Tags: - Key: Name Value: PublicSG TestEC2: Type: 'AWS::EC2::Instance' Properties: AvailabilityZone: us-west-2a ImageId: ami-0528a5175983e7f28 InstanceType: t2.micro KeyName: Ref: KeyName SubnetId: Ref: PublicSubnet SecurityGroupIds: - Ref: PublicSG Tags: - Key: Name Value: test TestEIP: Type: 'AWS::EC2::EIP' Properties: InstanceId: !Ref TestEC2