AWSTemplateFormatVersion: 2010-09-09
Description: >-
  Semi-fancy sample template for a httpd instance in AWS,
  that is still relatively easy to understand.
  From http://www.bolthole.com/AWS/
  
Parameters:
  InstanceArch:
    Description: EC2 instance type
    Type: String
    Default: t2.small
    AllowedValues:
      - t1.micro
      - t2.nano
      - t2.micro
      - t2.small
      - t2.medium
      - t2.large
  ImageId:
    Description: AMI Image to use
    Type: AWS::EC2::Image::Id
    Default: ami-7172b611
  KeyName:
    Type: AWS::EC2::KeyPair::KeyName
    Default: AWS-registered-ssh-key-here
    Description: Which ssh key will be allowed access

Resources:
  httpEC2:
    Type: 'AWS::EC2::Instance'
    Metadata:
      # See https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-init.html
      AWS::CloudFormation::Init:
        config:
          packages:
            yum:
              httpd: []
          services:
            sysvinit:
              httpd:
                enabled: true
          files:
            "/var/www/html/index.html":
              content: !Sub |
                AWS::CloudFormation::Init created index page for HTTP Demon<p>
                Boilerplate content goes here.<p>
		Blah blah blah
                
    Properties:
      InstanceType: !Ref 'InstanceArch'
      ImageId: !Ref 'ImageId'
      KeyName: !Ref 'KeyName'
      UserData:
        Fn::Base64: !Sub |
            #!/bin/bash -xe
            yum install -y aws-cfn-bootstrap
            /opt/aws/bin/cfn-init -v  --stack ${AWS::StackName} --resource httpEC2 --region=${AWS::Region}
            service httpd start

