Below is a generic ?CloudFormation example that can be re-used for your own templates (namely the Parameters, Mappings and selection of the ami-id in the EC2-Instance are interesting in that regard - The list of instance types should be complete too). The Mappings below Cover Wheezy-7.7 and Jessie as of 2014-10-24. Unfortunately, not all combinations of Region/Hypervisor/VolumeType/Release have an Amazon Image available.
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "CloudFormation Template for Debian Stable/Testing",
"Parameters" : {
"InstanceName" : {
"Description": "Instance name",
"Type" : "String"
},
"KeyName" : {
"Description" : "SSH Key Name",
"Type" : "String"
},
"DebianRelease" : {
"Description" : "Debian Release, Hypervisor and RootVolume Type (DebianWheezy77PvmEbs, DebianWheezy77PvmInstance, DebianWheezy77HvmEbs, DebianJessieHvmEbs) see: https://wiki.debian.org/Cloud/AmazonEC2Image/Wheezy and https://wiki.debian.org/Cloud/AmazonEC2Image/Jessie",
"Type" : "String",
"Default" : "DebianWheezy77PvmEbs",
"AllowedValues" : [ "DebianWheezy77PvmEbs", "DebianWheezy77PvmInstance", "DebianWheezy77HvmEBS", "DebianJessieHvmEbs" ]
},
"InstanceBits" : {
"Description" : "32 or 64 bits",
"Type" : "String",
"Default" : "64",
"AllowedValues" : [ "32", "64" ]
},
"InstanceType": {
"Description": "Instance Type (m1.small, etc. see: https://aws.amazon.com/ec2/instance-types/ and https://aws.amazon.com/amazon-linux-ami/instance-type-matrix/)",
"Type": "String",
"Default" : "t1.micro",
"AllowedValues": [
"t1.micro"
, "t2.micro"
, "t2.small"
, "t2.medium"
, "m1.small"
, "m1.medium"
, "m1.large"
, "m1.xlarge"
, "m2.xlarge"
, "m2.2xlarge"
, "m2.4xlarge"
, "m3.medium"
, "m3.large"
, "m3.xlarge"
, "m3.2xlarge"
, "c1.medium"
, "c1.xlarge"
, "cr1.8xlarge"
, "cc2.8xlarge"
, "c3.large"
, "c3.xlarge"
, "c3.2xlarge"
, "c3.4xlarge"
, "c3.8xlarge"
, "r3.large"
, "r3.xlarge"
, "r3.2xlarge"
, "r3.4xlarge"
, "r3.8xlarge"
, "cg1.4xlarge"
, "g2.2xlarge"
, "i2.xlarge"
, "i2.2xlarge"
, "i2.4xlarge"
, "i2.8xlarge"
, "hi1.4xlarge"
, "hs1.8xlarge"
, "hs1.8xlarge"
]
}
},
"Mappings": {
"DebianWheezy77PvmEbs" : {
"ap-northeast-1" : { "32": "ami-970b3a96", "64": "ami-0f0f3e0e" }
, "ap-southeast-1" : { "32": "ami-4e20011c", "64": "ami-70220322" }
, "ap-southeast-2" : { "32": "ami-0185e83b", "64": "ami-bd87ea87" }
, "eu-west-1" : { "32": "ami-c664cbb1", "64": "ami-9c62cdeb" }
, "eu-central-1" : { "32": "ami-522a1c4f", "64": "ami-4c2a1c51" }
, "sa-east-1" : { "32": "ami-3f7dc922", "64": "ami-a97dc9b4" }
, "us-east-1" : { "32": "ami-0258e26a", "64": "ami-2058e248" }
, "us-west-1" : { "32": "ami-c53d2880", "64": "ami-893c29cc" }
, "us-west-2" : { "32": "ami-677e3157", "64": "ami-df7c33ef" }
, "us-gov-west-1" : { "32": "ami-030e6820", "64": "ami-3d0e681e" }
, "cn-north-1" : { "64": "ami-e44ad8dd" }
},
"DebianWheezy77PvmInstance" : {
"ap-northeast-1" : { "32": "n/a", "64": "ami-21f6c720" }
, "ap-southeast-1" : { "32": "n/a", "64": "ami-24240576" }
, "ap-southeast-2" : { "32": "n/a", "64": "ami-e386ebd9" }
, "eu-west-1" : { "32": "n/a", "64": "ami-187fd06f" }
, "eu-central-1" : { "32": "n/a", "64": "ami-4a2a1c57" }
, "sa-east-1" : { "32": "n/a", "64": "ami-417eca5c" }
, "us-east-1" : { "32": "n/a", "64": "ami-bc4af0d4" }
, "us-west-1" : { "32": "n/a", "64": "ami-4b3e2b0e" }
, "us-west-2" : { "32": "n/a", "64": "ami-ff7a35cf" }
, "us-gov-west-1" : { "32": "n/a", "64": "n/a" }
, "cn-north-1" : { "32": "n/a", "64": "n/a" }
},
"DebianWheezy77HvmEbs" : {
"ap-northeast-1" : { "32": "n/a", "64": "ami-97f1c096" }
, "ap-southeast-1" : { "32": "n/a", "64": "ami-d822038a" }
, "ap-southeast-2" : { "32": "n/a", "64": "ami-ed87ead7" }
, "eu-west-1" : { "32": "n/a", "64": "ami-e261ce95" }
, "eu-central-1" : { "32": "n/a", "64": "ami-482a1c55" }
, "sa-east-1" : { "32": "n/a", "64": "ami-fd7dc9e0" }
, "us-east-1" : { "32": "n/a", "64": "ami-a458e2cc" }
, "us-west-1" : { "32": "n/a", "64": "ami-6f3f2a2a" }
, "us-west-2" : { "32": "n/a", "64": "ami-af7b349f" }
, "us-gov-west-1" : { "32": "n/a", "64": "ami-010e6822" }
, "cn-north-1" : { "32": "n/a", "64": "ami-e64ad8df" }
},
"DebianJessieHvmEbs" : {
"ap-northeast-1" : { "32": "n/a", "64": "ami-33a59432" }
, "ap-southeast-1" : { "32": "n/a", "64": "ami-24381976" }
, "ap-southeast-2" : { "32": "n/a", "64": "ami-cd97faf7" }
, "eu-west-1" : { "32": "n/a", "64": "ami-d2228da5" }
, "eu-central-1" : { "32": "n/a", "64": "n/a" }
, "sa-east-1" : { "32": "n/a", "64": "ami-f76cd8ea" }
, "us-east-1" : { "32": "n/a", "64": "ami-62e86d0a" }
, "us-west-1" : { "32": "n/a", "64": "ami-89d5c0cc" }
, "us-west-2" : { "32": "n/a", "64": "ami-b39cd383" }
, "us-gov-west-1" : { "32": "n/a", "64": "ami-9f0f69bc" }
, "cn-north-1" : { "32": "n/a", "64": "ami-264bd91f" }
}
},
"Conditions": {
},
"Resources" : {
"MyInstance" : {
"Type" : "AWS::EC2::Instance",
"Properties" : {
"SecurityGroups" : [
{ "Ref" : "SgTcpSsh" },
{ "Ref" : "SgTcpSsl" }
],
"KeyName" : { "Ref": "KeyName" },
"Tags" : [
{"Key": "Name", "Value": {"Ref" : "InstanceName"} }
],
"ImageId" : { "Fn::FindInMap" : [ { "Ref": "DebianRelease" }, { "Ref" : "AWS::Region" }, { "Ref" : "InstanceBits" } ] },
"InstanceType" : { "Ref" : "InstanceType" },
"UserData" : { "Fn::Base64" : "" }
}
},
"SgTcpSsh" : {
"Type" : "AWS::EC2::SecurityGroup",
"Properties" : {
"GroupDescription" : "SSH Ingress",
"SecurityGroupIngress" : [
{ "IpProtocol" : "tcp", "FromPort" : "22", "ToPort" : "22", "CidrIp" : "0.0.0.0/0" }
]
}
},
"SgTcpSsl" : {
"Type" : "AWS::EC2::SecurityGroup",
"Properties" : {
"GroupDescription" : "SSL Ingress",
"SecurityGroupIngress" : [
{ "IpProtocol" : "tcp", "FromPort" : "443", "ToPort" : "443", "CidrIp" : "0.0.0.0/0" }
]
}
}
},
"Outputs": {
"MyInstanceInstanceId" : { "Value" : { "Ref" : "MyInstance" } },
"MyInstanceAvailabilityZone" : { "Value" : { "Fn::GetAtt" : [ "MyInstance", "AvailabilityZone" ] } },
"MyInstancePrivateDnsName" : { "Value" : { "Fn::GetAtt" : [ "MyInstance", "PrivateDnsName" ] } },
"MyInstancePublicDnsName" : { "Value" : { "Fn::GetAtt" : [ "MyInstance", "PublicDnsName" ] } },
"MyInstancePrivateIp" : { "Value" : { "Fn::GetAtt" : [ "MyInstance", "PrivateIp" ] } },
"MyInstancePublicIp" : { "Value" : { "Fn::GetAtt" : [ "MyInstance", "PublicIp" ] } }
}
}