|
| 1 | +{ |
| 2 | + "AWSTemplateFormatVersion" : "2010-09-09", |
| 3 | + |
| 4 | + "Description" : "AWS Service Catalog sample template. Creates 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.", |
| 5 | + |
| 6 | + "Parameters" : { |
| 7 | + "KeyName": { |
| 8 | + "Description" : "Name of an existing EC2 key pair for SSH access to the EC2 instance.", |
| 9 | + "Type": "AWS::EC2::KeyPair::KeyName" |
| 10 | + }, |
| 11 | + |
| 12 | + "InstanceType" : { |
| 13 | + "Description" : "EC2 instance type.", |
| 14 | + "Type" : "String", |
| 15 | + "Default" : "t2.micro", |
| 16 | + "AllowedValues" : [ "t2.micro", "t2.small", "t2.medium"] |
| 17 | + }, |
| 18 | + |
| 19 | + "SSHLocation" : { |
| 20 | + "Description" : "The IP address range that can SSH to the EC2 instance.", |
| 21 | + "Type": "String", |
| 22 | + "MinLength": "9", |
| 23 | + "MaxLength": "18", |
| 24 | + "Default": "0.0.0.0/0", |
| 25 | + "AllowedPattern": "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})/(\\d{1,2})", |
| 26 | + "ConstraintDescription": "Must be a valid IP CIDR range of the form x.x.x.x/x." |
| 27 | + } |
| 28 | + }, |
| 29 | + |
| 30 | + "Metadata" : { |
| 31 | + "AWS::CloudFormation::Interface" : { |
| 32 | + "ParameterGroups" : [{ |
| 33 | + "Label" : {"default": "Instance configuration"}, |
| 34 | + "Parameters" : ["InstanceType"] |
| 35 | + },{ |
| 36 | + "Label" : {"default": "Security configuration"}, |
| 37 | + "Parameters" : ["KeyName", "SSHLocation"] |
| 38 | + }], |
| 39 | + "ParameterLabels" : { |
| 40 | + "InstanceType": {"default": "Server size:"}, |
| 41 | + "KeyName": {"default": "Key pair:"}, |
| 42 | + "SSHLocation": {"default": "CIDR range:"} |
| 43 | + } |
| 44 | + } |
| 45 | + }, |
| 46 | + |
| 47 | + "Mappings" : { |
| 48 | + "AWSRegionArch2AMI" : { |
| 49 | + "us-east-1" : { "HVM64" : "ami-08842d60" }, |
| 50 | + "us-west-2" : { "HVM64" : "ami-8786c6b7" }, |
| 51 | + "us-west-1" : { "HVM64" : "ami-cfa8a18a" }, |
| 52 | + "eu-west-1" : { "HVM64" : "ami-748e2903" }, |
| 53 | + "ap-southeast-1" : { "HVM64" : "ami-d6e1c584" }, |
| 54 | + "ap-northeast-1" : { "HVM64" : "ami-35072834" }, |
| 55 | + "ap-southeast-2" : { "HVM64" : "ami-fd4724c7" }, |
| 56 | + "sa-east-1" : { "HVM64" : "ami-956cc688" }, |
| 57 | + "cn-north-1" : { "HVM64" : "ami-ac57c595" }, |
| 58 | + "eu-central-1" : { "HVM64" : "ami-b43503a9" } |
| 59 | + } |
| 60 | + |
| 61 | + }, |
| 62 | + |
| 63 | + "Resources" : { |
| 64 | + "EC2Instance" : { |
| 65 | + "Type" : "AWS::EC2::Instance", |
| 66 | + "Properties" : { |
| 67 | + "InstanceType" : { "Ref" : "InstanceType" }, |
| 68 | + "SecurityGroups" : [ { "Ref" : "InstanceSecurityGroup" } ], |
| 69 | + "KeyName" : { "Ref" : "KeyName" }, |
| 70 | + "ImageId" : { "Fn::FindInMap" : [ "AWSRegionArch2AMI", { "Ref" : "AWS::Region" }, "HVM64" ] } |
| 71 | + } |
| 72 | + }, |
| 73 | + |
| 74 | + "InstanceSecurityGroup" : { |
| 75 | + "Type" : "AWS::EC2::SecurityGroup", |
| 76 | + "Properties" : { |
| 77 | + "GroupDescription" : "Enable SSH access via port 22", |
| 78 | + "SecurityGroupIngress" : [ { |
| 79 | + "IpProtocol" : "tcp", |
| 80 | + "FromPort" : "22", |
| 81 | + "ToPort" : "22", |
| 82 | + "CidrIp" : { "Ref" : "SSHLocation"} |
| 83 | + } ] |
| 84 | + } |
| 85 | + } |
| 86 | + }, |
| 87 | + |
| 88 | + "Outputs" : { |
| 89 | + "PublicDNSName" : { |
| 90 | + "Description" : "Public DNS name of the new EC2 instance", |
| 91 | + "Value" : { "Fn::GetAtt" : [ "EC2Instance", "PublicDnsName" ] } |
| 92 | + }, |
| 93 | + "PublicIPAddress" : { |
| 94 | + "Description" : "Public IP address of the new EC2 instance", |
| 95 | + "Value" : { "Fn::GetAtt" : [ "EC2Instance", "PublicIp" ] } |
| 96 | + } |
| 97 | + } |
| 98 | +} |
0 commit comments