-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsrpmhost-amzn.tmpl.json
231 lines (231 loc) · 5.59 KB
/
srpmhost-amzn.tmpl.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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "This template deploys an EL6 with RPM packaging tools pre-installed",
"Parameters": {
"AmiId": {
"Description": "ID of the AMI to launch",
"ConstraintDescription": "All ID's must start 'ami-' followed by an 8- to 17-character alphanumeric string.",
"Type": "String",
"AllowedPattern": "^ami-[0-9a-z]{8}$|^ami-[0-9a-z]{17}$"
},
"InstanceRole" : {
"Description" : "IAM instance role to apply to the instance(s)",
"Type" : "String",
"Default" : ""
},
"NoPublicIp": {
"Description": "Controls whether to assign the instance a public IP.",
"Type": "String",
"Default": "false",
"AllowedValues": [
"false",
"true"
]
},
"NoReboot": {
"Description": "Controls whether to reboot the instance as the last step of cfn-init execution",
"Type": "String",
"Default": "true",
"AllowedValues": [
"false",
"true"
]
},
"RootEBSsize": {
"Description": "Select size of root EBS volume (in GiB)",
"ConstraintDescription": "A numeric value between '8' and '50'.",
"Type": "Number",
"Default": "8",
"MinValue": "8",
"MaxValue": "50"
},
"RpmBucket": {
"Description": "Name of the Bucket for fetching/stowing RPMs",
"ConstraintDescription": "All characters must be legal DNS characters",
"Type": "String",
"AllowedPattern": "^[0-9a-z-]{4,48}$"
},
"SecurityGroupIds": {
"Description": "List of security groups to apply to the instance(s)",
"Type": "List<AWS::EC2::SecurityGroup::Id>"
},
"SubnetIds": {
"Type": "String",
"Description": "Subnet to associate to the Instance"
}
},
"Conditions": {
"AssignInstanceRole" :
{
"Fn::Not" : [
{
"Fn::Equals" : [
{
"Ref" : "InstanceRole"
},
""
]
}
]
},
"Reboot": {
"Fn::Not": [
{
"Fn::Equals": [
{
"Ref": "NoReboot"
},
"true"
]
}
]
},
"AssignPublicIp": {
"Fn::Not": [
{
"Fn::Equals": [
{
"Ref": "NoPublicIp"
},
"true"
]
}
]
}
},
"Mappings": {
"Distro2RootDevice": {
"RedHat": {
"DeviceName": "sda1"
},
"CentOS": {
"DeviceName": "sda1"
}
}
},
"Metadata": {
"AWS::CloudFormation::Interface": {
"ParameterGroups": [
{
"Label": {
"default": "EC2 Instance Configuration"
},
"Parameters": [
"AmiId",
"InstanceRole",
"NoReboot",
"RootEBSsize",
"RpmBucket"
]
},
{
"Label": {
"default": "Network Configuration"
},
"Parameters": [
"SubnetIds",
"SecurityGroupIds",
"NoPublicIp"
]
}
]
}
},
"Resources": {
"ValidationInstance": {
"Type": "AWS::EC2::Instance",
"Properties": {
"ImageId": {
"Ref": "AmiId"
},
"InstanceType": "t2.micro",
"IamInstanceProfile" : {
"Fn::If" : [
"AssignInstanceRole",
{ "Ref" : "InstanceRole" },
{ "Ref" : "AWS::NoValue" }
]
},
"Tags": [
{
"Key": "Name",
"Value": {
"Fn::Join": [
"",
[
{
"Ref": "AWS::StackName"
}
]
]
}
}
],
"BlockDeviceMappings": [
{
"DeviceName": "/dev/xvda",
"Ebs": {
"VolumeType": "gp2",
"VolumeSize" : {
"Ref": "RootEBSsize"
},
"DeleteOnTermination": "true"
}
}
],
"NetworkInterfaces": [
{
"DeviceIndex": "0",
"AssociatePublicIpAddress": {
"Fn::If": [
"AssignPublicIp",
"true",
"false"
]
},
"GroupSet": {
"Ref": "SecurityGroupIds"
},
"SubnetId": {
"Ref": "SubnetIds"
}
}
],
"UserData": {
"Fn::Base64": {
"Fn::Join": [
"",
[
"#cloud-config\n",
"\n",
"package_upgrade: true\n",
"\n",
"runcmd:\n",
" - yum install -y ec2* aws*\n",
" - |-\n",
" \n",
" # Download the SRPMs for all installed Amzn RPMs\n",
" for SRPM in $(rpm -qa ec2* aws* --qf '%{name}\\n')\n",
" do\n",
" echo yes | get_reference_source -p ${SRPM}\n",
" done\n",
" \n",
" # Load any new SRPMs to the S3 bukkit\n",
" aws s3 sync /usr/src/srpm/debug/ ",
"s3://",
{
"Ref": "RpmBucket"
},
"/SRPMS/\n"
]
]
}
}
},
"Metadata": {
"AWS::CloudFormation::Init": {
}
}
}
}
}