---
#
# Pre-requisites:
#     VPC must exist.
#     A Subnet in that VPC already created.
#     An internetwork gateway already created and attached to this VPC.
#     VPC Network ACL is default (Allows all input connections)
#     The route-table associated with the subnet must be edited to point to
#        internetwork-gateway for default route (0.0.0.0/0)
#     A Keypair with KeyName already exists
#
#
Resources:
  ThavaSSHGroup:
    Type: AWS::EC2::SecurityGroup
    Properties:
        GroupDescription: Allow ssh to client host
        VpcId:  vpc-04d30f416c91bd381
        SecurityGroupIngress:
        - IpProtocol: tcp
          FromPort: 22
          ToPort: 22
          CidrIp: 0.0.0.0/0
  MyInstance:
    Type: AWS::EC2::Instance
    Properties:
      AvailabilityZone: us-east-1c
      ImageId: ami-0ff8a91507f77f867
      # ImageId: ami-a4c7edb2  # Amazon Linux AMI 2017
      # ImageId: ami-0ff8a91507f77f867   # Amazon Linux AMI 2018
      # ImageId: ami-0c1481f2732d82982 # Ubuntu 2018 LTS
      InstanceType: t2.micro
      KeyName: aws-thava
      # InstanceType: t2.micro
      # Tip: aws ec2 describe-instances to see example existing configurations.

      # You must use NetworkInterfaces, to turn on auto Public IP.
      # If you explicitly specify NetworkInterfaces, you must specify
      # security group under this only as "GroupSet".
      NetworkInterfaces:
      - AssociatePublicIpAddress: "true"
        DeviceIndex: "0"
        SubnetId: subnet-0d3670d5f0e73533c
        GroupSet:
        - Ref: ThavaSSHGroup

