-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathwordpressuserdata.yaml
95 lines (95 loc) · 2.91 KB
/
wordpressuserdata.yaml
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
Parameters:
EnvironmentSize:
Type: String
Default: SMALL
AllowedValues:
- SMALL
- MEDIUM
- LARGE
Description: Select Environment Size (S,M,L)
DatabaseName:
Type: String
Default: wordpress
DatabaseUser:
Type: String
Default: wordpress
DatabasePassword:
Type: String
Default: w0rdpr355
NoEcho: true
Mappings:
RegionMap:
us-east-1:
"AMALINUX" : "ami-c481fad3" # AMALINUX SEP 2016
us-east-2:
"AMALINUX" : "ami-71ca9114" # AMALINUX SEP 2016
us-west-1:
"AMALINUX" : "ami-de347abe" # AMALINUX SEP 2016
us-west-2:
"AMALINUX" : "ami-b04e92d0" # AMALINUX SEP 2016
ca-central-1:
"AMALINUX" : "ami-eb20928f" # AMALINUX SEP 2016 v01
eu-west-1:
"AMALINUX" : "ami-d41d58a7" # AMALINUX SEP 2016
eu-central-1:
"AMALINUX" : "ami-0044b96f" # AMALINUX SEP 2016
eu-west-2:
"AMALINUX" : "ami-bfe0eadb" # AMALINUX SEP 2016 v01
ap-southeast-1:
"AMALINUX" : "ami-7243e611" # AMALINUX SEP 2016
ap-southeast-2:
"AMALINUX" : "ami-55d4e436" # AMALINUX SEP 2016
ap-northeast-2:
"AMALINUX" : "ami-a04297ce" # AMALINUX SEP 2016
ap-northeast-1:
"AMALINUX" : "ami-1a15c77b" # AMALINUX SEP 2016
ap-south-1:
"AMALINUX" : "ami-cacbbea5" # AMALINUX SEP 2016
sa-east-1:
"AMALINUX" : "ami-b777e4db" # AMALINUX SEP 2016
InstanceSize:
SMALL:
"EC2" : "t2.micro"
"DB" : "db.t2.micro"
MEDIUM:
"EC2" : "t2.small"
"DB" : "db.t2.small"
LARGE:
"EC2" : "t2.medium"
"DB" : "db.t2.medium"
Resources:
DB:
Type: "AWS::RDS::DBInstance"
Properties:
AllocatedStorage: 5
StorageType: gp2
DBInstanceClass: !FindInMap [InstanceSize, !Ref EnvironmentSize, DB] # Dynamic mapping + Pseudo Parameter
DBName: !Ref DatabaseName
Engine: MySQL
MasterUsername: !Ref DatabaseUser
MasterUserPassword: !Ref DatabasePassword
EC2:
Type: "AWS::EC2::Instance"
Properties:
ImageId: !FindInMap [RegionMap, !Ref "AWS::Region", AMALINUX] # Dynamic mapping + Pseudo Parameter
InstanceType: !FindInMap [InstanceSize, !Ref EnvironmentSize, EC2]
KeyName: AdvancedCFN
UserData:
"Fn::Base64":
!Sub |
#!/bin/bash
yum install httpd php mysql php-mysql -y
yum update -y
chkconfig httpd on
service httpd start
cd /var/www/html
wget https://wordpress.org/latest.tar.gz
tar -zxvf latest.tar.gz --strip 1
rm latest.tar.gz
cp wp-config-sample.php wp-config.php
sed -i 's/database_name_here/${DatabaseName}/g' wp-config.php
sed -i 's/localhost/${DB.Endpoint.Address}/g' wp-config.php
sed -i 's/username_here/${DatabaseUser}/g' wp-config.php
sed -i 's/password_here/${DatabasePassword}/g' wp-config.php
S3:
Type: "AWS::S3::Bucket"