drupalcluster 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/data/Drupal.yaml +487 -0
- data/data/Drupal_in_VPC.yaml +549 -0
- data/drupalcluster.gemspec +3 -4
- data/readme.md +15 -8
- metadata +16 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a1bb745a1cf7e2ddf027b8a07c905947e6cdf7a2
|
4
|
+
data.tar.gz: 3a9ec40a4c81ee677cf72ad132d292bcecd2fbb5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 373cc24151bce5d73fa0596324c8f61aa892a8078ad4960cf309b83137b9cfdfbdce62d6b5a625675d678be717611bd8785c24f193381880bc8357ee146bcd84
|
7
|
+
data.tar.gz: 15e27278221b1fba58c1bcf9c08e35f61b0254e4dbeee63819040bef2a8a2fdc607b0cfde51f76b427f452c932cf41f0755e7ecca41eaee1b7a35e31d51aa9c6
|
data/data/Drupal.yaml
ADDED
@@ -0,0 +1,487 @@
|
|
1
|
+
AWSTemplateFormatVersion: 2010-09-09
|
2
|
+
Description: >-
|
3
|
+
LAMP Multi-AZ with Drupal, using Elastic File System and cloud RDS db
|
4
|
+
Parameters:
|
5
|
+
VpcId:
|
6
|
+
Type: 'AWS::EC2::VPC::Id'
|
7
|
+
Description: VpcId of your existing Virtual Private Cloud (VPC)
|
8
|
+
ConstraintDescription: must be the VPC Id of an existing Virtual Private Cloud.
|
9
|
+
SubnetA:
|
10
|
+
Type: AWS::EC2::Subnet::Id
|
11
|
+
Description: A SubnetId in your Virtual Private Cloud (VPC)
|
12
|
+
ConstraintDescription: >-
|
13
|
+
Should be residing in the selected Virtual Private Cloud.
|
14
|
+
SubnetB:
|
15
|
+
Type: AWS::EC2::Subnet::Id
|
16
|
+
Description: A SubnetId from another availability zone than SubnetA in your Virtual Private Cloud (VPC)
|
17
|
+
ConstraintDescription: >-
|
18
|
+
Should be residing in the selected Virtual Private Cloud.
|
19
|
+
SubnetA and SubnetB must be in different Availability Zones.
|
20
|
+
KeyName:
|
21
|
+
Description: Name of an existing EC2 KeyPair to enable SSH access to the instances
|
22
|
+
Type: 'AWS::EC2::KeyPair::KeyName'
|
23
|
+
ConstraintDescription: must be the name of an existing EC2 KeyPair.
|
24
|
+
HealthCheckInterval:
|
25
|
+
Default: '10'
|
26
|
+
Description: How frequent CloudWatch should check health of instances (in seconds).
|
27
|
+
Type: String
|
28
|
+
UnhealthyAfter:
|
29
|
+
Default: '5'
|
30
|
+
Description: How many CloudWatch health checks to determine instance is out of order.
|
31
|
+
Type: String
|
32
|
+
PuppetMasterIp:
|
33
|
+
Description: The (internal) IP address of the puppet master for the system.
|
34
|
+
Type: String
|
35
|
+
DBName:
|
36
|
+
Default: drupaldb
|
37
|
+
Description: MySQL database name
|
38
|
+
Type: String
|
39
|
+
MinLength: '1'
|
40
|
+
MaxLength: '64'
|
41
|
+
AllowedPattern: '[a-zA-Z][a-zA-Z0-9]*'
|
42
|
+
ConstraintDescription: must begin with a letter and contain only alphanumeric characters.
|
43
|
+
DBUser:
|
44
|
+
Default: admin
|
45
|
+
Description: Username for MySQL database access
|
46
|
+
Type: String
|
47
|
+
MinLength: '1'
|
48
|
+
MaxLength: '16'
|
49
|
+
AllowedPattern: '[a-zA-Z][a-zA-Z0-9]*'
|
50
|
+
ConstraintDescription: must begin with a letter and contain only alphanumeric characters.
|
51
|
+
DBPassword:
|
52
|
+
Default: password
|
53
|
+
NoEcho: 'true'
|
54
|
+
Description: Password for MySQL database access
|
55
|
+
Type: String
|
56
|
+
MinLength: '8'
|
57
|
+
MaxLength: '41'
|
58
|
+
AllowedPattern: '[a-zA-Z0-9]*'
|
59
|
+
ConstraintDescription: Must contain at least 8 alphanumeric characters.
|
60
|
+
DBAllocatedStorage:
|
61
|
+
Default: '5'
|
62
|
+
Description: The size of the database (Gb)
|
63
|
+
Type: Number
|
64
|
+
MinValue: '5'
|
65
|
+
MaxValue: '1024'
|
66
|
+
ConstraintDescription: must be between 5 and 1024Gb.
|
67
|
+
MultiAZDatabase:
|
68
|
+
Default: 'false'
|
69
|
+
Description: Create a Multi-AZ MySQL Amazon RDS database instance
|
70
|
+
Type: String
|
71
|
+
AllowedValues:
|
72
|
+
- 'true'
|
73
|
+
- 'false'
|
74
|
+
ConstraintDescription: must be either true or false.
|
75
|
+
WebServerCapacity:
|
76
|
+
Default: '2'
|
77
|
+
Description: The initial nuber of WebServer instances
|
78
|
+
Type: Number
|
79
|
+
MinValue: '1'
|
80
|
+
MaxValue: '5'
|
81
|
+
ConstraintDescription: must be between 1 and 5 EC2 instances.
|
82
|
+
SSHLocation:
|
83
|
+
Description: ' The IP address range that can be used to SSH to the EC2 instances'
|
84
|
+
Type: String
|
85
|
+
MinLength: '9'
|
86
|
+
MaxLength: '18'
|
87
|
+
Default: 0.0.0.0/0
|
88
|
+
AllowedPattern: '(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/(\d{1,2})'
|
89
|
+
ConstraintDescription: must be a valid IP CIDR range of the form x.x.x.x/x.
|
90
|
+
Resources:
|
91
|
+
##
|
92
|
+
#
|
93
|
+
EFSSecurityGroup:
|
94
|
+
Type: 'AWS::EC2::SecurityGroup'
|
95
|
+
Properties:
|
96
|
+
GroupDescription: Enable HTTP access via port 80 locked down to the ELB and SSH access
|
97
|
+
SecurityGroupIngress:
|
98
|
+
- IpProtocol: tcp
|
99
|
+
FromPort: '0'
|
100
|
+
ToPort: '65535'
|
101
|
+
SourceSecurityGroupId: !Ref WebServerSecurityGroup
|
102
|
+
VpcId: !Ref VpcId
|
103
|
+
SharedDirectory:
|
104
|
+
Type: 'AWS::EFS::FileSystem'
|
105
|
+
Properties:
|
106
|
+
PerformanceMode: generalPurpose
|
107
|
+
FileSystemTags:
|
108
|
+
- Key: Name
|
109
|
+
Value: !Ref 'AWS::StackName'
|
110
|
+
MountPtA:
|
111
|
+
Type: AWS::EFS::MountTarget
|
112
|
+
Properties:
|
113
|
+
FileSystemId: !Ref SharedDirectory
|
114
|
+
SubnetId: !Ref SubnetA
|
115
|
+
SecurityGroups: [!Ref EFSSecurityGroup]
|
116
|
+
MountPtB:
|
117
|
+
Type: AWS::EFS::MountTarget
|
118
|
+
Properties:
|
119
|
+
FileSystemId: !Ref SharedDirectory
|
120
|
+
SubnetId: !Ref SubnetB
|
121
|
+
SecurityGroups: [!Ref EFSSecurityGroup]
|
122
|
+
##
|
123
|
+
#
|
124
|
+
ALBSecurityGroup:
|
125
|
+
Type: AWS::EC2::SecurityGroup
|
126
|
+
Properties:
|
127
|
+
GroupDescription: >-
|
128
|
+
Enable HTTP access via port 80 and SSH on port 22,
|
129
|
+
and also puppet on port 8140
|
130
|
+
SecurityGroupIngress:
|
131
|
+
- IpProtocol: tcp
|
132
|
+
FromPort: '80'
|
133
|
+
ToPort: '80'
|
134
|
+
CidrIp: !Ref SSHLocation
|
135
|
+
- IpProtocol: tcp
|
136
|
+
FromPort: '22'
|
137
|
+
ToPort: '22'
|
138
|
+
CidrIp: !Ref SSHLocation
|
139
|
+
- IpProtocol: tcp
|
140
|
+
FromPort: '8140'
|
141
|
+
ToPort: '8140'
|
142
|
+
CidrIp: !Sub '${PuppetMasterIp}/32'
|
143
|
+
VpcId: !Ref VpcId
|
144
|
+
ApplicationLoadBalancer:
|
145
|
+
Type: AWS::ElasticLoadBalancingV2::LoadBalancer
|
146
|
+
Properties:
|
147
|
+
SecurityGroups:
|
148
|
+
- !Ref ALBSecurityGroup
|
149
|
+
Subnets:
|
150
|
+
- !Ref SubnetA
|
151
|
+
- !Ref SubnetB
|
152
|
+
ALBListener:
|
153
|
+
Type: 'AWS::ElasticLoadBalancingV2::Listener'
|
154
|
+
Properties:
|
155
|
+
DefaultActions:
|
156
|
+
- Type: forward
|
157
|
+
TargetGroupArn: !Ref ALBTargetGroup
|
158
|
+
LoadBalancerArn: !Ref ApplicationLoadBalancer
|
159
|
+
Port: '80'
|
160
|
+
Protocol: HTTP
|
161
|
+
ALBTargetGroup:
|
162
|
+
Type: 'AWS::ElasticLoadBalancingV2::TargetGroup'
|
163
|
+
Properties:
|
164
|
+
HealthCheckIntervalSeconds: !Ref HealthCheckInterval
|
165
|
+
HealthCheckTimeoutSeconds: 5
|
166
|
+
HealthyThresholdCount: 2
|
167
|
+
Port: 80
|
168
|
+
Protocol: HTTP
|
169
|
+
UnhealthyThresholdCount: !Ref UnhealthyAfter
|
170
|
+
VpcId: !Ref VpcId
|
171
|
+
TargetGroupAttributes:
|
172
|
+
- Key: stickiness.enabled
|
173
|
+
Value: 'true'
|
174
|
+
- Key: stickiness.type
|
175
|
+
Value: lb_cookie
|
176
|
+
- Key: stickiness.lb_cookie.duration_seconds
|
177
|
+
Value: '30'
|
178
|
+
##
|
179
|
+
#
|
180
|
+
WebServerSecurityGroup:
|
181
|
+
Type: 'AWS::EC2::SecurityGroup'
|
182
|
+
Properties:
|
183
|
+
GroupDescription: Enable HTTP access via port 80 locked down to the ELB and SSH access
|
184
|
+
SecurityGroupIngress:
|
185
|
+
- IpProtocol: tcp
|
186
|
+
FromPort: '80'
|
187
|
+
ToPort: '80'
|
188
|
+
SourceSecurityGroupId: !Ref ALBSecurityGroup
|
189
|
+
- IpProtocol: tcp
|
190
|
+
FromPort: '22'
|
191
|
+
ToPort: '22'
|
192
|
+
CidrIp: !Ref SSHLocation
|
193
|
+
- IpProtocol: tcp
|
194
|
+
FromPort: '8140'
|
195
|
+
ToPort: '8140'
|
196
|
+
CidrIp: !Sub ${PuppetMasterIp}/32
|
197
|
+
VpcId: !Ref VpcId
|
198
|
+
WebServerGroup:
|
199
|
+
Type: 'AWS::AutoScaling::AutoScalingGroup'
|
200
|
+
Properties:
|
201
|
+
VPCZoneIdentifier:
|
202
|
+
- !Ref SubnetA
|
203
|
+
- !Ref SubnetB
|
204
|
+
LaunchConfigurationName: !Ref LaunchConfig
|
205
|
+
MinSize: '1'
|
206
|
+
MaxSize: '5'
|
207
|
+
DesiredCapacity: !Ref WebServerCapacity
|
208
|
+
TargetGroupARNs:
|
209
|
+
- !Ref ALBTargetGroup
|
210
|
+
CreationPolicy:
|
211
|
+
ResourceSignal:
|
212
|
+
Timeout: PT5M
|
213
|
+
Count: !Ref WebServerCapacity
|
214
|
+
UpdatePolicy:
|
215
|
+
AutoScalingRollingUpdate:
|
216
|
+
MinInstancesInService: '1'
|
217
|
+
MaxBatchSize: '1'
|
218
|
+
PauseTime: PT15M
|
219
|
+
WaitOnResourceSignals: 'true'
|
220
|
+
LaunchConfig:
|
221
|
+
Type: 'AWS::AutoScaling::LaunchConfiguration'
|
222
|
+
Metadata:
|
223
|
+
'AWS::CloudFormation::Init':
|
224
|
+
configSets:
|
225
|
+
drupal_install:
|
226
|
+
- install_cfn
|
227
|
+
- install_php
|
228
|
+
- start_httpd
|
229
|
+
- install_drupal
|
230
|
+
- install_puppet
|
231
|
+
install_cfn:
|
232
|
+
files:
|
233
|
+
/etc/cfn/cfn-hup.conf:
|
234
|
+
content: !Sub |
|
235
|
+
[main]
|
236
|
+
stack=${AWS::StackId}
|
237
|
+
region=${AWS::Region}
|
238
|
+
|
239
|
+
mode: '000400'
|
240
|
+
owner: root
|
241
|
+
group: root
|
242
|
+
/etc/cfn/hooks.d/cfn-auto-reloader.conf:
|
243
|
+
content: !Join
|
244
|
+
- ''
|
245
|
+
- - |
|
246
|
+
[cfn-auto-reloader-hook]
|
247
|
+
triggers=post.update
|
248
|
+
path=Resources.LaunchConfig.Metadata.AWS::CloudFormation::Init
|
249
|
+
- !Sub >
|
250
|
+
action=/opt/aws/bin/cfn-init -v
|
251
|
+
--stack ${AWS::StackName}
|
252
|
+
--resource LaunchConfig
|
253
|
+
--configsets drupal_install
|
254
|
+
--region ${AWS::Region}
|
255
|
+
- |
|
256
|
+
runas=root
|
257
|
+
mode: '000400'
|
258
|
+
owner: root
|
259
|
+
group: root
|
260
|
+
services:
|
261
|
+
sysvinit:
|
262
|
+
cfn-hup:
|
263
|
+
enabled: 'true'
|
264
|
+
ensureRunning: 'true'
|
265
|
+
files:
|
266
|
+
- /etc/cfn/cfn-hup.conf
|
267
|
+
- /etc/cfn/hooks.d/cfn-auto-reloader.conf
|
268
|
+
install_php:
|
269
|
+
packages:
|
270
|
+
yum:
|
271
|
+
php: []
|
272
|
+
php-mysql: []
|
273
|
+
php-cli: []
|
274
|
+
php-common: []
|
275
|
+
php-xml: []
|
276
|
+
php-pdo: []
|
277
|
+
php-gd: []
|
278
|
+
php-mbstring: []
|
279
|
+
start_httpd:
|
280
|
+
packages:
|
281
|
+
yum:
|
282
|
+
httpd: []
|
283
|
+
files:
|
284
|
+
/var/www/html/index.php:
|
285
|
+
content: !Sub
|
286
|
+
- |
|
287
|
+
<html>
|
288
|
+
<head>
|
289
|
+
<title>AWS CloudFormation PHP Sample</title>
|
290
|
+
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
291
|
+
</head>
|
292
|
+
<body>
|
293
|
+
<h1>Welcome to the AWS CloudFormation PHP Sample</h1>
|
294
|
+
<p/>
|
295
|
+
<?php
|
296
|
+
// Print out the current data and tie
|
297
|
+
print "The Current Date and Time is: <br/>";
|
298
|
+
print date("g:i A l, F j Y.");
|
299
|
+
?>
|
300
|
+
<p/>
|
301
|
+
<?php
|
302
|
+
// Setup a handle for CURL
|
303
|
+
$curl_handle=curl_init();
|
304
|
+
curl_setopt($curl_handle,CURLOPT_CONNECTTIMEOUT,2);
|
305
|
+
curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1);
|
306
|
+
// Get the hostname of the intance from the instance metadata
|
307
|
+
curl_setopt($curl_handle,CURLOPT_URL,'http://169.254.169.254/latest/meta-data/public-hostname');
|
308
|
+
$hostname = curl_exec($curl_handle);
|
309
|
+
if (empty($hostname))
|
310
|
+
{
|
311
|
+
print "Sorry, for some reason, we got no hostname back <br />";
|
312
|
+
}
|
313
|
+
else
|
314
|
+
{
|
315
|
+
print "Server = " . $hostname . "<br />";
|
316
|
+
}
|
317
|
+
// Get the instance-id of the intance from the instance metadata
|
318
|
+
curl_setopt($curl_handle,CURLOPT_URL,'http://169.254.169.254/latest/meta-data/instance-id');
|
319
|
+
$instanceid = curl_exec($curl_handle);
|
320
|
+
if (empty($instanceid))
|
321
|
+
{
|
322
|
+
print "Sorry, for some reason, we got no instance id back <br />";
|
323
|
+
}
|
324
|
+
else
|
325
|
+
{
|
326
|
+
print "EC2 instance-id = " . $instanceid . "<br />";
|
327
|
+
}
|
328
|
+
$Database = "${DB}";
|
329
|
+
$DBUser = "${DBUser}";
|
330
|
+
$DBPassword = "${DBPassword}";
|
331
|
+
print "Database = " . $Database . "<br />";
|
332
|
+
$dbconnection = mysql_connect($Database, $DBUser, $DBPassword)
|
333
|
+
or die("Could not connect: " . mysql_error());
|
334
|
+
print ("Connected to $Database successfully");
|
335
|
+
mysql_close($dbconnection);
|
336
|
+
?>
|
337
|
+
<h2>PHP Information</h2>
|
338
|
+
<p/>
|
339
|
+
<?php
|
340
|
+
phpinfo();
|
341
|
+
?>
|
342
|
+
</body>
|
343
|
+
</html>
|
344
|
+
- DB: !GetAtt [MySQLDatabase, Endpoint.Address]
|
345
|
+
mode: '000600'
|
346
|
+
owner: apache
|
347
|
+
group: apache
|
348
|
+
#/etc/httpd/conf/httpd.conf:
|
349
|
+
services:
|
350
|
+
sysvinit:
|
351
|
+
httpd:
|
352
|
+
enabled: 'true'
|
353
|
+
ensureRunning: 'true'
|
354
|
+
install_drupal:
|
355
|
+
packages:
|
356
|
+
yum:
|
357
|
+
nfs-utils: []
|
358
|
+
sources:
|
359
|
+
/tmp: https://ftp.drupal.org/files/projects/drupal-7.56.tar.gz
|
360
|
+
files:
|
361
|
+
/init/drupal_init:
|
362
|
+
content: !Sub
|
363
|
+
- |
|
364
|
+
#!/bin/bash
|
365
|
+
echo "This msg is from ${AWS::Region}" >> initfile
|
366
|
+
echo "EFS: ${EFS}" >> initfile
|
367
|
+
echo "DB: ${DB}" >> initfile
|
368
|
+
mkdir -p /efs
|
369
|
+
mount -t nfs4 -o nfsvers=4.1,hard,timeo=600,retrans=2 ${EFS}:/ /efs
|
370
|
+
cd /efs
|
371
|
+
if [ ! -d /efs/drupal ]
|
372
|
+
then
|
373
|
+
/init/first_meet_drupal
|
374
|
+
fi
|
375
|
+
ln -s /efs/drupal /var/www/html/drupal
|
376
|
+
- DB: !GetAtt [MySQLDatabase, Endpoint.Address]
|
377
|
+
EFS: !Sub >-
|
378
|
+
${SharedDirectory}.efs.${AWS::Region}.amazonaws.com
|
379
|
+
mode: '755'
|
380
|
+
/init/first_meet_drupal:
|
381
|
+
content: |
|
382
|
+
cp -r /tmp/drupal-7.56 /efs/drupal
|
383
|
+
cd /efs/drupal
|
384
|
+
mkdir files
|
385
|
+
cd sites/default
|
386
|
+
cp default.settings.php settings.php
|
387
|
+
# we might write db details in settings.php
|
388
|
+
# and resume presaved MySQL dump
|
389
|
+
cd ../..
|
390
|
+
chmod -R a+rw *
|
391
|
+
mode: '755'
|
392
|
+
commands:
|
393
|
+
init:
|
394
|
+
command: ./drupal_init >drupal_init.out 2>drupal_init.err
|
395
|
+
cwd: /init
|
396
|
+
install_puppet:
|
397
|
+
packages:
|
398
|
+
yum:
|
399
|
+
puppet: []
|
400
|
+
files:
|
401
|
+
/init/puppet_init:
|
402
|
+
content: !Sub |
|
403
|
+
#!/bin/bash
|
404
|
+
echo "${PuppetMasterIp} puppet" >> /etc/hosts
|
405
|
+
echo " server = puppet" >> /etc/puppet/puppet.conf
|
406
|
+
puppet agent --waitforcert 120
|
407
|
+
mode: '755'
|
408
|
+
services:
|
409
|
+
sysvinit:
|
410
|
+
puppet:
|
411
|
+
enabled: 'true'
|
412
|
+
ensureRunning: 'true'
|
413
|
+
commands:
|
414
|
+
init:
|
415
|
+
command: ./puppet_init >puppet_init.out 2>puppet_init.err
|
416
|
+
cwd: /init
|
417
|
+
ignoreErrors: true
|
418
|
+
Properties:
|
419
|
+
ImageId: ami-ea26ce85
|
420
|
+
InstanceType: t2.micro
|
421
|
+
SecurityGroups:
|
422
|
+
- !Ref WebServerSecurityGroup
|
423
|
+
KeyName: !Ref KeyName
|
424
|
+
UserData: !Base64
|
425
|
+
Fn::Sub: |
|
426
|
+
#!/bin/bash -xe
|
427
|
+
PROMPT="export PS1=\"\[\033[1;48m\]\u@\h-${AWS::StackName} \[\033[00m\]\W> \""
|
428
|
+
echo "$PROMPT" >> /root/.bashrc
|
429
|
+
echo "$PROMPT" >> /home/ec2-user/.bashrc
|
430
|
+
yum update -y # aws-cfn-bootstrap
|
431
|
+
# Install the files and packages from the metadata
|
432
|
+
opts="--stack ${AWS::StackName} --region ${AWS::Region} --resource"
|
433
|
+
cfn="/opt/aws/bin/cfn"
|
434
|
+
$cfn-init -v $opts LaunchConfig --configsets drupal_install
|
435
|
+
|
436
|
+
# Signal the status from cfn-init
|
437
|
+
$cfn-signal -e $? $opts WebServerGroup
|
438
|
+
##
|
439
|
+
#
|
440
|
+
DBEC2SecurityGroup:
|
441
|
+
Type: 'AWS::EC2::SecurityGroup'
|
442
|
+
Properties:
|
443
|
+
GroupDescription: Open database for access
|
444
|
+
SecurityGroupIngress:
|
445
|
+
- IpProtocol: tcp
|
446
|
+
FromPort: '3306'
|
447
|
+
ToPort: '3306'
|
448
|
+
SourceSecurityGroupId: !Ref WebServerSecurityGroup
|
449
|
+
VpcId: !Ref VpcId
|
450
|
+
MySQLDatabase:
|
451
|
+
Type: 'AWS::RDS::DBInstance'
|
452
|
+
Properties:
|
453
|
+
Engine: MySQL
|
454
|
+
DBName: !Ref DBName
|
455
|
+
MultiAZ: !Ref MultiAZDatabase
|
456
|
+
MasterUsername: !Ref DBUser
|
457
|
+
MasterUserPassword: !Ref DBPassword
|
458
|
+
DBInstanceClass: db.t2.micro
|
459
|
+
AllocatedStorage: !Ref DBAllocatedStorage
|
460
|
+
VPCSecurityGroups:
|
461
|
+
- !GetAtt [DBEC2SecurityGroup, GroupId]
|
462
|
+
##
|
463
|
+
#
|
464
|
+
Outputs:
|
465
|
+
WebsiteURL:
|
466
|
+
Description: |
|
467
|
+
URL for newly created Drupal cluster.
|
468
|
+
Installation required.
|
469
|
+
Value: !Join
|
470
|
+
- ''
|
471
|
+
- - 'http://'
|
472
|
+
- !GetAtt [ApplicationLoadBalancer, DNSName]
|
473
|
+
- '/drupal'
|
474
|
+
DatabaseURL:
|
475
|
+
Description: >
|
476
|
+
URL for its MySQL database cluster.
|
477
|
+
|
478
|
+
Please fill it in the Advanced tab of
|
479
|
+
database settings during Drupal installation.
|
480
|
+
Value: !GetAtt [MySQLDatabase, Endpoint.Address]
|
481
|
+
DatabaseName:
|
482
|
+
Value: !Ref DBName
|
483
|
+
DatabaseUser:
|
484
|
+
Value: !Ref DBUser
|
485
|
+
#DatabasePassword:
|
486
|
+
# Description: (top secret)
|
487
|
+
# Value: !Ref DBPassword
|
@@ -0,0 +1,549 @@
|
|
1
|
+
AWSTemplateFormatVersion: 2010-09-09
|
2
|
+
Description: >-
|
3
|
+
LAMP Multi-AZ with Drupal, using Elastic File System and cloud RDS db,
|
4
|
+
all within a new VPC
|
5
|
+
Parameters:
|
6
|
+
VpcId:
|
7
|
+
Type: 'AWS::EC2::VPC::Id'
|
8
|
+
Description: The default VpcId, dummy parameter - not in use
|
9
|
+
ConstraintDescription: must be the VPC Id of an existing Virtual Private Cloud.
|
10
|
+
SubnetA:
|
11
|
+
Type: AWS::EC2::Subnet::Id
|
12
|
+
Description: Default subnet 1 in the default VPC, dummy parameter - not in use
|
13
|
+
ConstraintDescription: >-
|
14
|
+
Should be residing in the selected Virtual Private Cloud.
|
15
|
+
SubnetB:
|
16
|
+
Type: AWS::EC2::Subnet::Id
|
17
|
+
Description: Default subnet 2 in the default VPC, dummy parameter - not in use
|
18
|
+
ConstraintDescription: >-
|
19
|
+
Should be residing in the selected Virtual Private Cloud.
|
20
|
+
KeyName:
|
21
|
+
Description: Name of an existing EC2 KeyPair to enable SSH access to the instances
|
22
|
+
Type: 'AWS::EC2::KeyPair::KeyName'
|
23
|
+
ConstraintDescription: must be the name of an existing EC2 KeyPair.
|
24
|
+
HealthCheckInterval:
|
25
|
+
Default: '10'
|
26
|
+
Description: How frequent CloudWatch should check health of instances (in seconds).
|
27
|
+
Type: String
|
28
|
+
UnhealthyAfter:
|
29
|
+
Default: '5'
|
30
|
+
Description: How many CloudWatch health checks to determine instance is out of order.
|
31
|
+
Type: String
|
32
|
+
PuppetMasterIp:
|
33
|
+
Description: The (internal) IP address of the puppet master for the system.
|
34
|
+
Type: String
|
35
|
+
DBName:
|
36
|
+
Default: drupaldb
|
37
|
+
Description: MySQL database name
|
38
|
+
Type: String
|
39
|
+
MinLength: '1'
|
40
|
+
MaxLength: '64'
|
41
|
+
AllowedPattern: '[a-zA-Z][a-zA-Z0-9]*'
|
42
|
+
ConstraintDescription: must begin with a letter and contain only alphanumeric characters.
|
43
|
+
DBUser:
|
44
|
+
Default: admin
|
45
|
+
Description: Username for MySQL database access
|
46
|
+
Type: String
|
47
|
+
MinLength: '1'
|
48
|
+
MaxLength: '16'
|
49
|
+
AllowedPattern: '[a-zA-Z][a-zA-Z0-9]*'
|
50
|
+
ConstraintDescription: must begin with a letter and contain only alphanumeric characters.
|
51
|
+
DBPassword:
|
52
|
+
Default: password
|
53
|
+
NoEcho: 'true'
|
54
|
+
Description: Password for MySQL database access
|
55
|
+
Type: String
|
56
|
+
MinLength: '8'
|
57
|
+
MaxLength: '41'
|
58
|
+
AllowedPattern: '[a-zA-Z0-9]*'
|
59
|
+
ConstraintDescription: Must contain at least 8 alphanumeric characters.
|
60
|
+
DBAllocatedStorage:
|
61
|
+
Default: '5'
|
62
|
+
Description: The size of the database (Gb)
|
63
|
+
Type: Number
|
64
|
+
MinValue: '5'
|
65
|
+
MaxValue: '1024'
|
66
|
+
ConstraintDescription: must be between 5 and 1024Gb.
|
67
|
+
MultiAZDatabase:
|
68
|
+
Default: 'false'
|
69
|
+
Description: Create a Multi-AZ MySQL Amazon RDS database instance
|
70
|
+
Type: String
|
71
|
+
AllowedValues:
|
72
|
+
- 'true'
|
73
|
+
- 'false'
|
74
|
+
ConstraintDescription: must be either true or false.
|
75
|
+
WebServerCapacity:
|
76
|
+
Default: '2'
|
77
|
+
Description: The initial nuber of WebServer instances
|
78
|
+
Type: Number
|
79
|
+
MinValue: '1'
|
80
|
+
MaxValue: '5'
|
81
|
+
ConstraintDescription: must be between 1 and 5 EC2 instances.
|
82
|
+
SSHLocation:
|
83
|
+
Description: ' The IP address range that can be used to SSH to the EC2 instances'
|
84
|
+
Type: String
|
85
|
+
MinLength: '9'
|
86
|
+
MaxLength: '18'
|
87
|
+
Default: 0.0.0.0/0
|
88
|
+
AllowedPattern: '(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/(\d{1,2})'
|
89
|
+
ConstraintDescription: must be a valid IP CIDR range of the form x.x.x.x/x.
|
90
|
+
Resources:
|
91
|
+
##
|
92
|
+
#
|
93
|
+
Network:
|
94
|
+
Type: AWS::EC2::VPC
|
95
|
+
Properties:
|
96
|
+
CidrBlock: 12.1.0.0/16
|
97
|
+
EnableDnsHostnames: true
|
98
|
+
Tags:
|
99
|
+
- Key: Name
|
100
|
+
Value: !Sub ${AWS::StackName}-Network
|
101
|
+
MySubnetA:
|
102
|
+
Type: AWS::EC2::Subnet
|
103
|
+
Properties:
|
104
|
+
VpcId: !Ref Network
|
105
|
+
CidrBlock: 12.1.0.0/20
|
106
|
+
AvailabilityZone: !Sub ${AWS::Region}a
|
107
|
+
MapPublicIpOnLaunch: true
|
108
|
+
Tags:
|
109
|
+
- Key: Name
|
110
|
+
Value: !Sub ${AWS::StackName}-subnet-a
|
111
|
+
MySubnetB:
|
112
|
+
Type: AWS::EC2::Subnet
|
113
|
+
Properties:
|
114
|
+
VpcId: !Ref Network
|
115
|
+
CidrBlock: 12.1.16.0/20
|
116
|
+
AvailabilityZone: !Sub ${AWS::Region}b
|
117
|
+
MapPublicIpOnLaunch: true
|
118
|
+
Tags:
|
119
|
+
- Key: Name
|
120
|
+
Value: !Sub ${AWS::StackName}-subnet-b
|
121
|
+
#
|
122
|
+
Gateway:
|
123
|
+
Type: AWS::EC2::InternetGateway
|
124
|
+
Properties:
|
125
|
+
Tags:
|
126
|
+
- Key: Name
|
127
|
+
Value: !Sub ${AWS::StackName}-GW
|
128
|
+
AttachGateway:
|
129
|
+
Type: AWS::EC2::VPCGatewayAttachment
|
130
|
+
Properties:
|
131
|
+
VpcId: !Ref Network
|
132
|
+
InternetGatewayId: !Ref Gateway
|
133
|
+
ServerRouteTable:
|
134
|
+
Type: AWS::EC2::RouteTable
|
135
|
+
Properties:
|
136
|
+
VpcId: !Ref Network
|
137
|
+
ServerRoute:
|
138
|
+
Type: AWS::EC2::Route
|
139
|
+
DependsOn: Gateway
|
140
|
+
Properties:
|
141
|
+
RouteTableId: !Ref ServerRouteTable
|
142
|
+
DestinationCidrBlock: 0.0.0.0/0
|
143
|
+
GatewayId: !Ref Gateway
|
144
|
+
RouteTableAssociationA:
|
145
|
+
Type: AWS::EC2::SubnetRouteTableAssociation
|
146
|
+
Properties:
|
147
|
+
SubnetId: !Ref MySubnetA
|
148
|
+
RouteTableId: !Ref ServerRouteTable
|
149
|
+
RouteTableAssociationB:
|
150
|
+
Type: AWS::EC2::SubnetRouteTableAssociation
|
151
|
+
Properties:
|
152
|
+
SubnetId: !Ref MySubnetB
|
153
|
+
RouteTableId: !Ref ServerRouteTable
|
154
|
+
NetworkInterfaceA:
|
155
|
+
Type: AWS::EC2::NetworkInterface
|
156
|
+
Properties:
|
157
|
+
Description: Application network interface.
|
158
|
+
SourceDestCheck: 'false'
|
159
|
+
GroupSet:
|
160
|
+
- !Ref ALBSecurityGroup
|
161
|
+
SubnetId: !Ref MySubnetA
|
162
|
+
Tags:
|
163
|
+
- Key: Name
|
164
|
+
Value: !Sub ${AWS::StackName}-eni-a
|
165
|
+
NetworkInterfaceB:
|
166
|
+
Type: AWS::EC2::NetworkInterface
|
167
|
+
Properties:
|
168
|
+
Description: Application network interface.
|
169
|
+
SourceDestCheck: 'false'
|
170
|
+
GroupSet:
|
171
|
+
- !Ref ALBSecurityGroup
|
172
|
+
SubnetId: !Ref MySubnetB
|
173
|
+
Tags:
|
174
|
+
- Key: Name
|
175
|
+
Value: !Sub ${AWS::StackName}-eni-b
|
176
|
+
#
|
177
|
+
DBSubnetGroup:
|
178
|
+
Type: AWS::RDS::DBSubnetGroup
|
179
|
+
Properties:
|
180
|
+
DBSubnetGroupDescription: One more resource for full connectivity within the VPC
|
181
|
+
SubnetIds:
|
182
|
+
- !Ref MySubnetA
|
183
|
+
- !Ref MySubnetB
|
184
|
+
##
|
185
|
+
#
|
186
|
+
EFSSecurityGroup:
|
187
|
+
Type: 'AWS::EC2::SecurityGroup'
|
188
|
+
Properties:
|
189
|
+
GroupDescription: Enable HTTP access via port 80 locked down to the ELB and SSH access
|
190
|
+
SecurityGroupIngress:
|
191
|
+
- IpProtocol: tcp
|
192
|
+
FromPort: '0'
|
193
|
+
ToPort: '65535'
|
194
|
+
SourceSecurityGroupId: !Ref WebServerSecurityGroup
|
195
|
+
VpcId: !Ref Network
|
196
|
+
SharedDirectory:
|
197
|
+
Type: 'AWS::EFS::FileSystem'
|
198
|
+
Properties:
|
199
|
+
PerformanceMode: generalPurpose
|
200
|
+
FileSystemTags:
|
201
|
+
- Key: Name
|
202
|
+
Value: !Ref 'AWS::StackName'
|
203
|
+
MountPtA:
|
204
|
+
Type: AWS::EFS::MountTarget
|
205
|
+
Properties:
|
206
|
+
FileSystemId: !Ref SharedDirectory
|
207
|
+
SubnetId: !Ref MySubnetA
|
208
|
+
SecurityGroups: [!Ref EFSSecurityGroup]
|
209
|
+
MountPtB:
|
210
|
+
Type: AWS::EFS::MountTarget
|
211
|
+
Properties:
|
212
|
+
FileSystemId: !Ref SharedDirectory
|
213
|
+
SubnetId: !Ref MySubnetB
|
214
|
+
SecurityGroups: [!Ref EFSSecurityGroup]
|
215
|
+
##
|
216
|
+
#
|
217
|
+
ALBSecurityGroup:
|
218
|
+
Type: AWS::EC2::SecurityGroup
|
219
|
+
Properties:
|
220
|
+
GroupDescription: >-
|
221
|
+
Enable HTTP access via port 80 and SSH on port 22
|
222
|
+
SecurityGroupIngress:
|
223
|
+
- IpProtocol: tcp
|
224
|
+
FromPort: '80'
|
225
|
+
ToPort: '80'
|
226
|
+
CidrIp: !Ref SSHLocation
|
227
|
+
- IpProtocol: tcp
|
228
|
+
FromPort: '22'
|
229
|
+
ToPort: '22'
|
230
|
+
CidrIp: !Ref SSHLocation
|
231
|
+
VpcId: !Ref Network
|
232
|
+
ApplicationLoadBalancer:
|
233
|
+
Type: AWS::ElasticLoadBalancingV2::LoadBalancer
|
234
|
+
Properties:
|
235
|
+
SecurityGroups:
|
236
|
+
- !Ref ALBSecurityGroup
|
237
|
+
Subnets:
|
238
|
+
- !Ref MySubnetA
|
239
|
+
- !Ref MySubnetB
|
240
|
+
ALBListener:
|
241
|
+
Type: 'AWS::ElasticLoadBalancingV2::Listener'
|
242
|
+
Properties:
|
243
|
+
DefaultActions:
|
244
|
+
- Type: forward
|
245
|
+
TargetGroupArn: !Ref ALBTargetGroup
|
246
|
+
LoadBalancerArn: !Ref ApplicationLoadBalancer
|
247
|
+
Port: '80'
|
248
|
+
Protocol: HTTP
|
249
|
+
ALBTargetGroup:
|
250
|
+
Type: 'AWS::ElasticLoadBalancingV2::TargetGroup'
|
251
|
+
Properties:
|
252
|
+
HealthCheckIntervalSeconds: !Ref HealthCheckInterval
|
253
|
+
HealthCheckTimeoutSeconds: 5
|
254
|
+
HealthyThresholdCount: 2
|
255
|
+
Port: 80
|
256
|
+
Protocol: HTTP
|
257
|
+
UnhealthyThresholdCount: !Ref UnhealthyAfter
|
258
|
+
VpcId: !Ref Network
|
259
|
+
TargetGroupAttributes:
|
260
|
+
- Key: stickiness.enabled
|
261
|
+
Value: 'true'
|
262
|
+
- Key: stickiness.type
|
263
|
+
Value: lb_cookie
|
264
|
+
- Key: stickiness.lb_cookie.duration_seconds
|
265
|
+
Value: '30'
|
266
|
+
##
|
267
|
+
#
|
268
|
+
WebServerSecurityGroup:
|
269
|
+
Type: 'AWS::EC2::SecurityGroup'
|
270
|
+
Properties:
|
271
|
+
GroupDescription: Enable HTTP access via port 80 locked down to the ELB and SSH access
|
272
|
+
SecurityGroupIngress:
|
273
|
+
- IpProtocol: tcp
|
274
|
+
FromPort: '80'
|
275
|
+
ToPort: '80'
|
276
|
+
SourceSecurityGroupId: !Ref ALBSecurityGroup
|
277
|
+
- IpProtocol: tcp
|
278
|
+
FromPort: '22'
|
279
|
+
ToPort: '22'
|
280
|
+
CidrIp: !Ref SSHLocation
|
281
|
+
VpcId: !Ref Network
|
282
|
+
WebServerGroup:
|
283
|
+
Type: 'AWS::AutoScaling::AutoScalingGroup'
|
284
|
+
Properties:
|
285
|
+
VPCZoneIdentifier:
|
286
|
+
- !Ref MySubnetA
|
287
|
+
- !Ref MySubnetB
|
288
|
+
LaunchConfigurationName: !Ref LaunchConfig
|
289
|
+
MinSize: '1'
|
290
|
+
MaxSize: '5'
|
291
|
+
DesiredCapacity: !Ref WebServerCapacity
|
292
|
+
TargetGroupARNs:
|
293
|
+
- !Ref ALBTargetGroup
|
294
|
+
CreationPolicy:
|
295
|
+
ResourceSignal:
|
296
|
+
Timeout: PT5M
|
297
|
+
Count: !Ref WebServerCapacity
|
298
|
+
UpdatePolicy:
|
299
|
+
AutoScalingRollingUpdate:
|
300
|
+
MinInstancesInService: '1'
|
301
|
+
MaxBatchSize: '1'
|
302
|
+
PauseTime: PT15M
|
303
|
+
WaitOnResourceSignals: 'true'
|
304
|
+
LaunchConfig:
|
305
|
+
Type: 'AWS::AutoScaling::LaunchConfiguration'
|
306
|
+
Metadata:
|
307
|
+
'AWS::CloudFormation::Init':
|
308
|
+
configSets:
|
309
|
+
drupal_install:
|
310
|
+
- install_cfn
|
311
|
+
- install_php
|
312
|
+
- start_httpd
|
313
|
+
- install_drupal
|
314
|
+
install_cfn:
|
315
|
+
files:
|
316
|
+
/etc/cfn/cfn-hup.conf:
|
317
|
+
content: !Sub |
|
318
|
+
[main]
|
319
|
+
stack=${AWS::StackId}
|
320
|
+
region=${AWS::Region}
|
321
|
+
|
322
|
+
mode: '000400'
|
323
|
+
owner: root
|
324
|
+
group: root
|
325
|
+
/etc/cfn/hooks.d/cfn-auto-reloader.conf:
|
326
|
+
content: !Join
|
327
|
+
- ''
|
328
|
+
- - |
|
329
|
+
[cfn-auto-reloader-hook]
|
330
|
+
triggers=post.update
|
331
|
+
path=Resources.LaunchConfig.Metadata.AWS::CloudFormation::Init
|
332
|
+
- !Sub >
|
333
|
+
action=/opt/aws/bin/cfn-init -v
|
334
|
+
--stack ${AWS::StackName}
|
335
|
+
--resource LaunchConfig
|
336
|
+
--configsets drupal_install
|
337
|
+
--region ${AWS::Region}
|
338
|
+
- |
|
339
|
+
runas=root
|
340
|
+
mode: '000400'
|
341
|
+
owner: root
|
342
|
+
group: root
|
343
|
+
services:
|
344
|
+
sysvinit:
|
345
|
+
cfn-hup:
|
346
|
+
enabled: 'true'
|
347
|
+
ensureRunning: 'true'
|
348
|
+
files:
|
349
|
+
- /etc/cfn/cfn-hup.conf
|
350
|
+
- /etc/cfn/hooks.d/cfn-auto-reloader.conf
|
351
|
+
install_php:
|
352
|
+
packages:
|
353
|
+
yum:
|
354
|
+
php: []
|
355
|
+
php-mysql: []
|
356
|
+
php-cli: []
|
357
|
+
php-common: []
|
358
|
+
php-xml: []
|
359
|
+
php-pdo: []
|
360
|
+
php-gd: []
|
361
|
+
php-mbstring: []
|
362
|
+
start_httpd:
|
363
|
+
packages:
|
364
|
+
yum:
|
365
|
+
httpd: []
|
366
|
+
files:
|
367
|
+
/var/www/html/index.php:
|
368
|
+
content: !Sub
|
369
|
+
- |
|
370
|
+
<html>
|
371
|
+
<head>
|
372
|
+
<title>AWS CloudFormation PHP Sample</title>
|
373
|
+
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
374
|
+
</head>
|
375
|
+
<body>
|
376
|
+
<h1>Welcome to the AWS CloudFormation PHP Sample</h1>
|
377
|
+
<p/>
|
378
|
+
<?php
|
379
|
+
// Print out the current data and tie
|
380
|
+
print "The Current Date and Time is: <br/>";
|
381
|
+
print date("g:i A l, F j Y.");
|
382
|
+
?>
|
383
|
+
<p/>
|
384
|
+
<?php
|
385
|
+
// Setup a handle for CURL
|
386
|
+
$curl_handle=curl_init();
|
387
|
+
curl_setopt($curl_handle,CURLOPT_CONNECTTIMEOUT,2);
|
388
|
+
curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1);
|
389
|
+
// Get the hostname of the intance from the instance metadata
|
390
|
+
curl_setopt($curl_handle,CURLOPT_URL,'http://169.254.169.254/latest/meta-data/public-hostname');
|
391
|
+
$hostname = curl_exec($curl_handle);
|
392
|
+
if (empty($hostname))
|
393
|
+
{
|
394
|
+
print "Sorry, for some reason, we got no hostname back <br />";
|
395
|
+
}
|
396
|
+
else
|
397
|
+
{
|
398
|
+
print "Server = " . $hostname . "<br />";
|
399
|
+
}
|
400
|
+
// Get the instance-id of the intance from the instance metadata
|
401
|
+
curl_setopt($curl_handle,CURLOPT_URL,'http://169.254.169.254/latest/meta-data/instance-id');
|
402
|
+
$instanceid = curl_exec($curl_handle);
|
403
|
+
if (empty($instanceid))
|
404
|
+
{
|
405
|
+
print "Sorry, for some reason, we got no instance id back <br />";
|
406
|
+
}
|
407
|
+
else
|
408
|
+
{
|
409
|
+
print "EC2 instance-id = " . $instanceid . "<br />";
|
410
|
+
}
|
411
|
+
$Database = "${DB}";
|
412
|
+
$DBUser = "${DBUser}";
|
413
|
+
$DBPassword = "${DBPassword}";
|
414
|
+
print "Database = " . $Database . "<br />";
|
415
|
+
$dbconnection = mysql_connect($Database, $DBUser, $DBPassword)
|
416
|
+
or die("Could not connect: " . mysql_error());
|
417
|
+
print ("Connected to $Database successfully");
|
418
|
+
mysql_close($dbconnection);
|
419
|
+
?>
|
420
|
+
<h2>PHP Information</h2>
|
421
|
+
<p/>
|
422
|
+
<?php
|
423
|
+
phpinfo();
|
424
|
+
?>
|
425
|
+
</body>
|
426
|
+
</html>
|
427
|
+
- DB: !GetAtt [MySQLDatabase, Endpoint.Address]
|
428
|
+
mode: '000600'
|
429
|
+
owner: apache
|
430
|
+
group: apache
|
431
|
+
#/etc/httpd/conf/httpd.conf:
|
432
|
+
services:
|
433
|
+
sysvinit:
|
434
|
+
httpd:
|
435
|
+
enabled: 'true'
|
436
|
+
ensureRunning: 'true'
|
437
|
+
install_drupal:
|
438
|
+
packages:
|
439
|
+
yum:
|
440
|
+
nfs-utils: []
|
441
|
+
sources:
|
442
|
+
/tmp: https://ftp.drupal.org/files/projects/drupal-7.56.tar.gz
|
443
|
+
files:
|
444
|
+
/init/drupal_init:
|
445
|
+
content: !Sub
|
446
|
+
- |
|
447
|
+
#!/bin/bash
|
448
|
+
echo "This msg is from ${AWS::Region}" >> initfile
|
449
|
+
echo "EFS: ${EFS}" >> initfile
|
450
|
+
echo "DB: ${DB}" >> initfile
|
451
|
+
mkdir -p /efs
|
452
|
+
mount -t nfs4 -o nfsvers=4.1,hard,timeo=600,retrans=2 ${EFS}:/ /efs
|
453
|
+
cd /efs
|
454
|
+
if [ ! -d /efs/drupal ]
|
455
|
+
then
|
456
|
+
/init/first_meet_drupal
|
457
|
+
fi
|
458
|
+
ln -s /efs/drupal /var/www/html/drupal
|
459
|
+
- DB: !GetAtt [MySQLDatabase, Endpoint.Address]
|
460
|
+
EFS: !Sub >-
|
461
|
+
${SharedDirectory}.efs.${AWS::Region}.amazonaws.com
|
462
|
+
mode: '755'
|
463
|
+
/init/first_meet_drupal:
|
464
|
+
content: |
|
465
|
+
cp -r /tmp/drupal-7.56 /efs/drupal
|
466
|
+
cd /efs/drupal
|
467
|
+
mkdir files
|
468
|
+
cd sites/default
|
469
|
+
cp default.settings.php settings.php
|
470
|
+
# we might write db details in settings.php
|
471
|
+
# and resume presaved MySQL dump
|
472
|
+
cd ../..
|
473
|
+
chmod -R a+rw *
|
474
|
+
mode: '755'
|
475
|
+
commands:
|
476
|
+
init:
|
477
|
+
command: ./drupal_init >drupal_init.out 2>drupal_init.err
|
478
|
+
cwd: /init
|
479
|
+
Properties:
|
480
|
+
ImageId: ami-ea26ce85
|
481
|
+
InstanceType: t2.micro
|
482
|
+
SecurityGroups:
|
483
|
+
- !Ref WebServerSecurityGroup
|
484
|
+
KeyName: !Ref KeyName
|
485
|
+
UserData: !Base64
|
486
|
+
Fn::Sub: |
|
487
|
+
#!/bin/bash -xe
|
488
|
+
PROMPT="export PS1=\"\[\033[1;48m\]\u@\h-${AWS::StackName} \[\033[00m\]\W> \""
|
489
|
+
echo "$PROMPT" >> /root/.bashrc
|
490
|
+
echo "$PROMPT" >> /home/ec2-user/.bashrc
|
491
|
+
yum update -y # aws-cfn-bootstrap
|
492
|
+
# Install the files and packages from the metadata
|
493
|
+
opts="--stack ${AWS::StackName} --region ${AWS::Region} --resource"
|
494
|
+
cfn="/opt/aws/bin/cfn"
|
495
|
+
$cfn-init -v $opts LaunchConfig --configsets drupal_install
|
496
|
+
|
497
|
+
# Signal the status from cfn-init
|
498
|
+
$cfn-signal -e $? $opts WebServerGroup
|
499
|
+
##
|
500
|
+
#
|
501
|
+
DBEC2SecurityGroup:
|
502
|
+
Type: 'AWS::EC2::SecurityGroup'
|
503
|
+
Properties:
|
504
|
+
GroupDescription: Open database for access
|
505
|
+
SecurityGroupIngress:
|
506
|
+
- IpProtocol: tcp
|
507
|
+
FromPort: '3306'
|
508
|
+
ToPort: '3306'
|
509
|
+
SourceSecurityGroupId: !Ref WebServerSecurityGroup
|
510
|
+
VpcId: !Ref Network
|
511
|
+
MySQLDatabase:
|
512
|
+
Type: 'AWS::RDS::DBInstance'
|
513
|
+
Properties:
|
514
|
+
Engine: MySQL
|
515
|
+
DBName: !Ref DBName
|
516
|
+
MultiAZ: !Ref MultiAZDatabase
|
517
|
+
MasterUsername: !Ref DBUser
|
518
|
+
MasterUserPassword: !Ref DBPassword
|
519
|
+
DBInstanceClass: db.t2.micro
|
520
|
+
DBSubnetGroupName: !Ref DBSubnetGroup
|
521
|
+
AllocatedStorage: !Ref DBAllocatedStorage
|
522
|
+
VPCSecurityGroups:
|
523
|
+
- !GetAtt [DBEC2SecurityGroup, GroupId]
|
524
|
+
##
|
525
|
+
#
|
526
|
+
Outputs:
|
527
|
+
WebsiteURL:
|
528
|
+
Description: |
|
529
|
+
URL for newly created Drupal cluster.
|
530
|
+
Installation required.
|
531
|
+
Value: !Join
|
532
|
+
- ''
|
533
|
+
- - 'http://'
|
534
|
+
- !GetAtt [ApplicationLoadBalancer, DNSName]
|
535
|
+
- '/drupal'
|
536
|
+
DatabaseURL:
|
537
|
+
Description: >
|
538
|
+
URL for its MySQL database cluster.
|
539
|
+
|
540
|
+
Please fill it in the Advanced tab of
|
541
|
+
database settings during Drupal installation.
|
542
|
+
Value: !GetAtt [MySQLDatabase, Endpoint.Address]
|
543
|
+
DatabaseName:
|
544
|
+
Value: !Ref DBName
|
545
|
+
DatabaseUser:
|
546
|
+
Value: !Ref DBUser
|
547
|
+
#DatabasePassword:
|
548
|
+
# Description: (top secret)
|
549
|
+
# Value: !Ref DBPassword
|
data/drupalcluster.gemspec
CHANGED
@@ -2,17 +2,16 @@
|
|
2
2
|
Gem::Specification.new do |s|
|
3
3
|
|
4
4
|
s.name = 'drupalcluster'
|
5
|
-
s.version = '0.1.
|
5
|
+
s.version = '0.1.2'
|
6
6
|
s.license = "Nonstandard"
|
7
7
|
s.date = '2017-11-03'
|
8
8
|
s.summary = "Create/delete/test a multiserver Drupal site in Amazon cloud."
|
9
9
|
s.description = File.new("readme.md").read
|
10
10
|
s.authors = ["Bertalan Pecsi"]
|
11
11
|
s.email = 'zellerede@gmail.com'
|
12
|
-
|
13
|
-
s.files = all_files.select {|fname| fname !~ /html/}
|
12
|
+
s.files = `git ls-files`.split $/
|
14
13
|
s.executables = ["drupalcluster"]
|
15
|
-
s.homepage = 'https://github.com/zellerede/
|
14
|
+
s.homepage = 'https://github.com/zellerede/drupalcluster'
|
16
15
|
s.require_paths = ["bin",
|
17
16
|
"lib"]
|
18
17
|
|
data/readme.md
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
|
2
|
+
|
1
3
|
+drupalcluster+ is a command line tool to quickly
|
2
4
|
deploy a Drupal hosting cluster of a scalable amount [2..5]
|
3
5
|
of virtual webservers.
|
@@ -6,8 +8,10 @@ of virtual webservers.
|
|
6
8
|
Your AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY should be either
|
7
9
|
environment variables, or set in ~/.aws/credentials.
|
8
10
|
|
9
|
-
The configuration file contains additional details for the cluster
|
10
|
-
|
11
|
+
The configuration file contains additional details for the cluster,
|
12
|
+
including an ssh KeyName that's needed to access the servers.
|
13
|
+
The KeyName defaults to 'Drupal', easiest if it's precreated.
|
14
|
+
$HOME/.drc/drupalcluster.conf
|
11
15
|
|
12
16
|
This is a demo version only, builds Drupal on HTTP connection.
|
13
17
|
Don't use it seriously.
|
@@ -15,10 +19,13 @@ Especially, don't post personal/sensitive data on your Drupal site.
|
|
15
19
|
|
16
20
|
==== Commands
|
17
21
|
|
18
|
-
create
|
19
|
-
check [
|
20
|
-
delete
|
21
|
-
test
|
22
|
-
attack
|
23
|
-
list
|
22
|
+
create name -- Creates a Drupal hosting cluster
|
23
|
+
check [name] -- Checks the status of creation/deletion
|
24
|
+
delete name -- Deletes permanently the given cluster
|
25
|
+
test name|url -- Sends a simple HTTP GET to the URL (of the given cluster)
|
26
|
+
attack instance -- Permanently terminates the given server instance
|
27
|
+
list -- Lists the recently created/deleted clusters.
|
28
|
+
|
29
|
+
-----------------------
|
24
30
|
|
31
|
+
*** Please contribute to add rspec's ***
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: drupalcluster
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bertalan Pecsi
|
@@ -38,18 +38,21 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '2.8'
|
41
|
-
description: "+drupalcluster+ is a command line tool to quickly\ndeploy a Drupal
|
41
|
+
description: "\n\n+drupalcluster+ is a command line tool to quickly\ndeploy a Drupal
|
42
42
|
hosting cluster of a scalable amount [2..5]\nof virtual webservers.\n\n!! AWS identity
|
43
43
|
is required for this script !!\nYour AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY should
|
44
44
|
be either\nenvironment variables, or set in ~/.aws/credentials.\n\nThe configuration
|
45
|
-
file contains additional details for the cluster
|
46
|
-
|
47
|
-
\
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
45
|
+
file contains additional details for the cluster,\nincluding an ssh KeyName that's
|
46
|
+
needed to access the servers.\nThe KeyName defaults to 'Drupal', easiest if it's
|
47
|
+
precreated.\n $HOME/.drc/drupalcluster.conf\n\nThis is a demo version only, builds
|
48
|
+
Drupal on HTTP connection.\nDon't use it seriously. \nEspecially, don't post personal/sensitive
|
49
|
+
data on your Drupal site.\n\n==== Commands\n\n create name -- Creates a Drupal
|
50
|
+
hosting cluster\n check [name] -- Checks the status of creation/deletion \n
|
51
|
+
\ delete name -- Deletes permanently the given cluster\n test name|url --
|
52
|
+
Sends a simple HTTP GET to the URL (of the given cluster)\n attack instance --
|
53
|
+
Permanently terminates the given server instance\n list -- Lists the
|
54
|
+
recently created/deleted clusters.\n\n-----------------------\n\n*** Please contribute
|
55
|
+
to add rspec's ***\n"
|
53
56
|
email: zellerede@gmail.com
|
54
57
|
executables:
|
55
58
|
- drupalcluster
|
@@ -58,6 +61,8 @@ extra_rdoc_files: []
|
|
58
61
|
files:
|
59
62
|
- bin/drupalcluster
|
60
63
|
- conf/drupalcluster.conf
|
64
|
+
- data/Drupal.yaml
|
65
|
+
- data/Drupal_in_VPC.yaml
|
61
66
|
- drupalcluster.gemspec
|
62
67
|
- lib/aws/drupal_aws.rb
|
63
68
|
- lib/cli_framework.rb
|
@@ -65,7 +70,7 @@ files:
|
|
65
70
|
- lib/etc/utilities.rb
|
66
71
|
- lib/netting.rb
|
67
72
|
- readme.md
|
68
|
-
homepage: https://github.com/zellerede/
|
73
|
+
homepage: https://github.com/zellerede/drupalcluster
|
69
74
|
licenses:
|
70
75
|
- Nonstandard
|
71
76
|
metadata: {}
|