-
Notifications
You must be signed in to change notification settings - Fork 59
/
cf-template.json
133 lines (115 loc) · 3.56 KB
/
cf-template.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
{
"Description" : "Test of Elastic IP association",
"AWSTemplateFormatVersion" : "2010-09-09",
"Parameters" : {
"InstanceType" : {
"Description" : "EC2 instance type for backup server",
"Type" : "String",
"Default" : "t2.micro"
},
"KeyName" : {
"Description" : "Key pair name",
"Type" : "String"
}
},
"Mappings" : {
"AWSInstanceType2Arch" : {
"t1.micro": { "Arch" : "64" }
},
"AWSRegionArch2AMI": {
"eu-west-1": {
"32" : "NOT_YET_SUPPORTED",
"64" : "ami-76817c1e",
"64HVM" : "NOT_YET_SUPPORTED"
}
}
},
"Resources" : {
"LaunchConfiguration" : {
"Type": "AWS::AutoScaling::LaunchConfiguration",
"Properties": {
"ImageId" : {
"Fn::FindInMap" : [
"AWSRegionArch2AMI",
{ "Ref" : "AWS::Region" },
{ "Fn::FindInMap" : [ "AWSInstanceType2Arch", { "Ref" : "InstanceType" }, "Arch" ] }
]
},
"AssociatePublicIpAddress" : true,
"InstanceType" : { "Ref" : "InstanceType" },
"SecurityGroups" : [ { "Ref" : "SecurityGroup" } ],
"KeyName" : { "Ref" : "KeyName" },
"UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [
"#!/bin/bash -v\n",
"# Install cfn bootstraping tools\n",
"apt-get update\n",
"apt-get -y install python-setuptools python-pip\n",
"easy_install https://s3.amazonaws.com/cloudformation-examples/aws-cfn-bootstrap-latest.tar.gz\n",
"# Make sure we have the latest aws-ec2-assign-elastic-ip\n",
"pip install aws-ec2-assign-elastic-ip==0.1.0b1 || error_exit 'Failed upgrading aws-ec2-assign-elastic-ip to the latest version'\n",
"# Assign an Elastic IP\n",
"aws-ec2-assign-elastic-ip",
" --access-key ", { "Ref" : "AccessKeys" },
" --secret-key ", { "Fn::GetAtt": ["AccessKeys", "SecretAccessKey"] },
" --region ", { "Ref" : "AWS::Region" },
" >> /var/log/aws-ec2-assign-elastic-ip.log\n"
]]}}
}
},
"AutoScalingGroup": {
"Type": "AWS::AutoScaling::AutoScalingGroup",
"Properties": {
"LaunchConfigurationName": { "Ref": "LaunchConfiguration" },
"MinSize": "1",
"MaxSize": "1",
"Tags" : [
{
"Key" : "Name",
"Value" : { "Ref" : "AWS::StackName" },
"PropagateAtLaunch" : true
}
]
}
},
"User" : {
"Type" : "AWS::IAM::User",
"Properties" : {
"Path": "/",
"Policies": [
{
"PolicyName": "cloudformation",
"PolicyDocument": { "Statement":[{
"Effect":"Allow",
"Action":[
"cloudformation:DescribeStackResource",
"ec2:*"
],
"Resource":"*"
}]}
}
]
}
},
"AccessKeys" : {
"Type" : "AWS::IAM::AccessKey",
"Properties" : {
"UserName" : {"Ref": "User"}
}
},
"EIP1" : { "Type" : "AWS::EC2::EIP" },
"EIP2" : { "Type" : "AWS::EC2::EIP" },
"EIP3" : { "Type" : "AWS::EC2::EIP" },
"SecurityGroup" : {
"Type": "AWS::EC2::SecurityGroup",
"Properties" : {
"GroupDescription": "Security group",
"SecurityGroupIngress": [
{ "IpProtocol": "tcp", "FromPort": "22", "ToPort": "22", "CidrIp": "0.0.0.0/0" }
],
"Tags" : [
{ "Key": "Name", "Value" : { "Ref" : "AWS::StackName" } }
]
}
}
}
}