Skip to content

Instantly share code, notes, and snippets.

@ryankelley
Created November 17, 2015 18:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ryankelley/15821abddeb131db6727 to your computer and use it in GitHub Desktop.
Save ryankelley/15821abddeb131db6727 to your computer and use it in GitHub Desktop.
AWS-EC2 instance CF Template
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "AWS CloudFormation Sample Template EC2InstanceWithSecurityGroupSample: Create an Amazon EC2 instance running the Amazon Linux AMI. The AMI is chosen based on the region in which the stack is run. This example creates an EC2 security group for the instance to give you SSH access. **WARNING** This template creates an Amazon EC2 instance. You will be billed for the AWS resources used if you create a stack from this template.",
"Parameters" : {
"KeyName" : {
"Description" : "Name of an existing EC2 KeyPair to enable SSH access to the instance",
"Type" : "AWS::EC2::KeyPair::KeyName",
"ConstraintDescription" : "must be the name of an existing EC2 KeyPair."
},
"SubnetId" : {
"Type" : "AWS::EC2::Subnet::Id",
"Description" : "ID of existing VPC Subnet"
},
"SecurityGroupId" : {
"Description" : "Id of existing SecurityGroup",
"Type" : "AWS::EC2::SecurityGroup::Id"
},
"InstanceType" : {
"Type" : "String"
}
},
"Mappings" : {
"AWSInstanceType2Arch" : {
"t1.micro" : {
"Arch" : "PV64"
},
"t2.micro" : {
"Arch" : "HVM64"
},
"t2.small" : {
"Arch" : "HVM64"
},
"t2.medium" : {
"Arch" : "HVM64"
},
"m1.small" : {
"Arch" : "PV64"
},
"m1.medium" : {
"Arch" : "PV64"
},
"m1.large" : {
"Arch" : "PV64"
},
"m1.xlarge" : {
"Arch" : "PV64"
},
"m2.xlarge" : {
"Arch" : "PV64"
},
"m2.2xlarge" : {
"Arch" : "PV64"
},
"m2.4xlarge" : {
"Arch" : "PV64"
},
"m3.medium" : {
"Arch" : "HVM64"
},
"m3.large" : {
"Arch" : "HVM64"
},
"m3.xlarge" : {
"Arch" : "HVM64"
},
"m3.2xlarge" : {
"Arch" : "HVM64"
},
"c1.medium" : {
"Arch" : "PV64"
},
"c1.xlarge" : {
"Arch" : "PV64"
},
"c3.large" : {
"Arch" : "HVM64"
},
"c3.xlarge" : {
"Arch" : "HVM64"
},
"c3.2xlarge" : {
"Arch" : "HVM64"
},
"c3.4xlarge" : {
"Arch" : "HVM64"
},
"c3.8xlarge" : {
"Arch" : "HVM64"
},
"c4.large" : {
"Arch" : "HVM64"
},
"c4.xlarge" : {
"Arch" : "HVM64"
},
"c4.2xlarge" : {
"Arch" : "HVM64"
},
"c4.4xlarge" : {
"Arch" : "HVM64"
},
"c4.8xlarge" : {
"Arch" : "HVM64"
},
"g2.2xlarge" : {
"Arch" : "HVMG2"
},
"r3.large" : {
"Arch" : "HVM64"
},
"r3.xlarge" : {
"Arch" : "HVM64"
},
"r3.2xlarge" : {
"Arch" : "HVM64"
},
"r3.4xlarge" : {
"Arch" : "HVM64"
},
"r3.8xlarge" : {
"Arch" : "HVM64"
},
"i2.xlarge" : {
"Arch" : "HVM64"
},
"i2.2xlarge" : {
"Arch" : "HVM64"
},
"i2.4xlarge" : {
"Arch" : "HVM64"
},
"i2.8xlarge" : {
"Arch" : "HVM64"
},
"d2.xlarge" : {
"Arch" : "HVM64"
},
"d2.2xlarge" : {
"Arch" : "HVM64"
},
"d2.4xlarge" : {
"Arch" : "HVM64"
},
"d2.8xlarge" : {
"Arch" : "HVM64"
},
"hi1.4xlarge" : {
"Arch" : "HVM64"
},
"hs1.8xlarge" : {
"Arch" : "HVM64"
},
"cr1.8xlarge" : {
"Arch" : "HVM64"
},
"cc2.8xlarge" : {
"Arch" : "HVM64"
}
},
"AWSInstanceType2NATArch" : {
"t1.micro" : {
"Arch" : "NATPV64"
},
"t2.micro" : {
"Arch" : "NATHVM64"
},
"t2.small" : {
"Arch" : "NATHVM64"
},
"t2.medium" : {
"Arch" : "NATHVM64"
},
"m1.small" : {
"Arch" : "NATPV64"
},
"m1.medium" : {
"Arch" : "NATPV64"
},
"m1.large" : {
"Arch" : "NATPV64"
},
"m1.xlarge" : {
"Arch" : "NATPV64"
},
"m2.xlarge" : {
"Arch" : "NATPV64"
},
"m2.2xlarge" : {
"Arch" : "NATPV64"
},
"m2.4xlarge" : {
"Arch" : "NATPV64"
},
"m3.medium" : {
"Arch" : "NATHVM64"
},
"m3.large" : {
"Arch" : "NATHVM64"
},
"m3.xlarge" : {
"Arch" : "NATHVM64"
},
"m3.2xlarge" : {
"Arch" : "NATHVM64"
},
"c1.medium" : {
"Arch" : "NATPV64"
},
"c1.xlarge" : {
"Arch" : "NATPV64"
},
"c3.large" : {
"Arch" : "NATHVM64"
},
"c3.xlarge" : {
"Arch" : "NATHVM64"
},
"c3.2xlarge" : {
"Arch" : "NATHVM64"
},
"c3.4xlarge" : {
"Arch" : "NATHVM64"
},
"c3.8xlarge" : {
"Arch" : "NATHVM64"
},
"c4.large" : {
"Arch" : "NATHVM64"
},
"c4.xlarge" : {
"Arch" : "NATHVM64"
},
"c4.2xlarge" : {
"Arch" : "NATHVM64"
},
"c4.4xlarge" : {
"Arch" : "NATHVM64"
},
"c4.8xlarge" : {
"Arch" : "NATHVM64"
},
"g2.2xlarge" : {
"Arch" : "NATHVMG2"
},
"r3.large" : {
"Arch" : "NATHVM64"
},
"r3.xlarge" : {
"Arch" : "NATHVM64"
},
"r3.2xlarge" : {
"Arch" : "NATHVM64"
},
"r3.4xlarge" : {
"Arch" : "NATHVM64"
},
"r3.8xlarge" : {
"Arch" : "NATHVM64"
},
"i2.xlarge" : {
"Arch" : "NATHVM64"
},
"i2.2xlarge" : {
"Arch" : "NATHVM64"
},
"i2.4xlarge" : {
"Arch" : "NATHVM64"
},
"i2.8xlarge" : {
"Arch" : "NATHVM64"
},
"d2.xlarge" : {
"Arch" : "NATHVM64"
},
"d2.2xlarge" : {
"Arch" : "NATHVM64"
},
"d2.4xlarge" : {
"Arch" : "NATHVM64"
},
"d2.8xlarge" : {
"Arch" : "NATHVM64"
},
"hi1.4xlarge" : {
"Arch" : "NATHVM64"
},
"hs1.8xlarge" : {
"Arch" : "NATHVM64"
},
"cr1.8xlarge" : {
"Arch" : "NATHVM64"
},
"cc2.8xlarge" : {
"Arch" : "NATHVM64"
}
},
"AWSRegionArch2AMI" : {
"us-east-1" : {
"PV64" : "ami-5fb8c835",
"HVM64" : "ami-60b6c60a",
"HVMG2" : "ami-e998ea83"
},
"us-west-2" : {
"PV64" : "ami-d93622b8",
"HVM64" : "ami-f0091d91",
"HVMG2" : "ami-315f4850"
},
"us-west-1" : {
"PV64" : "ami-56ea8636",
"HVM64" : "ami-d5ea86b5",
"HVMG2" : "ami-943956f4"
},
"eu-west-1" : {
"PV64" : "ami-95e33ce6",
"HVM64" : "ami-bff32ccc",
"HVMG2" : "ami-83fd23f0"
},
"eu-central-1" : {
"PV64" : "ami-794a5915",
"HVM64" : "ami-bc5b48d0",
"HVMG2" : "ami-ba1a09d6"
},
"ap-northeast-1" : {
"PV64" : "ami-393c1957",
"HVM64" : "ami-383c1956",
"HVMG2" : "ami-08e5c166"
},
"ap-southeast-1" : {
"PV64" : "ami-34bd7a57",
"HVM64" : "ami-c9b572aa",
"HVMG2" : "ami-5a15d239"
},
"ap-southeast-2" : {
"PV64" : "ami-ced887ad",
"HVM64" : "ami-48d38c2b",
"HVMG2" : "ami-0c1a446f"
},
"sa-east-1" : {
"PV64" : "ami-7d15ad11",
"HVM64" : "ami-6817af04",
"HVMG2" : "NOT_SUPPORTED"
},
"cn-north-1" : {
"PV64" : "ami-18ac6575",
"HVM64" : "ami-43a36a2e",
"HVMG2" : "NOT_SUPPORTED"
}
}
},
"Resources" : {
"EC2Instance" : {
"Type" : "AWS::EC2::Instance",
"Properties" : {
"InstanceType" : {
"Ref" : "InstanceType"
},
"KeyName" : {
"Ref" : "KeyName"
},
"ImageId" : {
"Fn::FindInMap" : [
"AWSRegionArch2AMI", {
"Ref" : "AWS::Region"
}, {
"Fn::FindInMap" : [
"AWSInstanceType2Arch", {
"Ref" : "InstanceType"
},
"Arch"
]
}
]
},
"NetworkInterfaces":[{
"AssociatePublicIpAddress": "true",
"DeviceIndex":"0",
"GroupSet": [{ "Ref" : "SecurityGroupId" }],
"SubnetId": { "Ref" : "SubnetId" }
}]
}
}
},
"Outputs" : {
"InstanceId" : {
"Description" : "InstanceId of the newly created EC2 instance",
"Value" : {
"Ref" : "EC2Instance"
}
},
"AZ" : {
"Description" : "Availability Zone of the newly created EC2 instance",
"Value" : {
"Fn::GetAtt" : [
"EC2Instance",
"AvailabilityZone"
]
}
},
"PublicDNS" : {
"Description" : "Public DNSName of the newly created EC2 instance",
"Value" : {
"Fn::GetAtt" : [
"EC2Instance",
"PublicDnsName"
]
}
},
"PublicIP" : {
"Description" : "Public IP address of the newly created EC2 instance",
"Value" : {
"Fn::GetAtt" : [
"EC2Instance",
"PublicIp"
]
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment