CloudFormation: Windows based instance with few disks

ec2In this example I want to show you how easily AWS resources can be created with CloudFormation templates.

So let’s take a look at template itself:

{
  "AWSTemplateFormatVersion": "2010-09-09",
  "Description": "test EC2",

  "Parameters": {
    "KeyName": {
      "Description" : "Name of an existing EC2 KeyPair",
      "Type": "AWS::EC2::KeyPair::KeyName",
      "ConstraintDescription" : "must be the name of an existing EC2 KeyPair."
    }
  },

  "Resources": {

    "WebServerSecurityGroup" : {
    "Type" : "AWS::EC2::SecurityGroup",
    "Properties" : {
      "GroupDescription" : "Enable http access from anywhere and RDP from office",
      "SecurityGroupIngress" : [
         {"IpProtocol" : "tcp", "FromPort" : "80", "ToPort" : "80", "CidrIp" : "0.0.0.0/0"},
         {"IpProtocol" : "tcp", "FromPort" : "3389", "ToPort" : "3389", "CidrIp" : "94.74.72.228/32"}
        ]
    }
  },

    "EC2Instance": {
      "Type" : "AWS::EC2::Instance",
       "Properties" : {
         "ImageId" : "ami-c8a9baa2",
         "InstanceInitiatedShutdownBehavior" : "stop",
         "InstanceType" : "c4.large",
         "KeyName" : {
          "Ref": "KeyName"
          },
         "Monitoring" : "true",
         "SecurityGroupIds" : [ {
          "Fn::GetAtt" : [ "WebServerSecurityGroup" , "GroupId" ]
          } ],
         "Tenancy" : "default",
         "BlockDeviceMappings" : [
           {
              "DeviceName" : "/dev/sda1",
              "Ebs" : { "VolumeSize" : "50" , "VolumeType" : "io1" , "Iops" : "1500" }
           } ],
         "Volumes" : [
          {
            "VolumeId" : { "Ref" : "EBSDisk" }, "Device" : "/dev/sdk"
          } ]
       }
    },

    "EBSDisk": {
     "Type":"AWS::EC2::Volume",
     "Properties" : {
        "AvailabilityZone" : "us-east-1a",
        "Encrypted" : "true",
        "Iops" : "600",
        "Size" : "20",
        "VolumeType" : "io1"
     }
    }
   }
  }

I hope this info will be useful for you, and if you need any help feel free to use contact from on the main page.