{ "AWSTemplateFormatVersion" : "2010-09-09", "Description" : "Create an EC2 instance.", "Parameters" : { "KeyName" : { "Description" : "Name of an existing EC2 KeyPair to enable SSH access to the instance", "Type" : "String", "MinLength" : "1", "MaxLength" : "255", "AllowedPattern" : "[\x20-\x7E]*", "ConstraintDescription" : "can contain only ASCII characters." }, "SSHFrom" : { "Description" : "Lockdown SSH access (default can be accessed from anywhere)", "Type" : "String", "MinLength" : "9", "MaxLength" : "18", "Default" : "0.0.0.0/0", "AllowedPattern" : "(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/(\d{1,2})", "ConstraintDescription" : "must be a valid CIDR range of the form x.x.x.x/x." } }, "Mappings" : { "AmazonLinuxAMI" : { "us-east-1": { "AMI": "ami-b66ed3de" }, "us-west-1": { "AMI": "ami-4b6f650e" }, "us-west-2": { "AMI": "ami-b5a7ea85" }, "eu-west-1": { "AMI": "ami-6e7bd919" }, "sa-east-1": { "AMI": "ami-8737829a" }, "ap-southeast-1": { "AMI": "ami-ac5c7afe" }, "ap-southeast-2": { "AMI": "ami-63f79559" }, "ap-northeast-1": { "AMI": "ami-4985b048" } } }, "Resources" : { "EC2Instance" : { "Type" : "AWS::EC2::Instance", "Properties" : { "SecurityGroups" : [{ "Ref" : "InstanceSecurityGroup" } ], "InstanceType" : "t2.micro", "KeyName" : { "Ref" : "KeyName" }, "ImageId" : { "Fn::FindInMap" : [ "AmazonLinuxAMI", { "Ref" : "AWS::Region" }, "AMI" ] } } }, "InstanceSecurityGroup" : { "Type" : "AWS::EC2::SecurityGroup", "Properties" : { "GroupDescription" : "Enable SSH access via port 22", "SecurityGroupIngress" : [{ "IpProtocol" : "tcp", "FromPort" : "22", "ToPort" : "22", "CidrIp" : { "Ref" : "SSHFrom" } } ] } }, "MountPoint" : { "Type" : "AWS::EC2::VolumeAttachment", "Properties" : { "InstanceId" : { "Ref" : "EC2Instance" }, "VolumeId" : { "Ref" : "NewVolume" }, "Device" : "/dev/sdh" } }, "NewVolume" : { "Type" : "AWS::EC2::Volume", "Properties" : { "Size" : "100", "VolumeType" : "gp2", "AvailabilityZone" : { "Fn::GetAtt" : ["EC2Instance", "AvailabilityZone"] } } } }, "Outputs" : { "InstanceId" : { "Description" : "InstanceId of the newly created EC2 instance", "Value" : { "Ref" : "EC2Instance" } } } }