-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathwordpressuserdata
128 lines (127 loc) · 3.01 KB
/
wordpressuserdata
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
{
"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"
}
},
"Mappings": {
"RegionMap": {
"us-east-1": {
"AMALINUX": "ami-c481fad3"
},
"us-east-2": {
"AMALINUX": "ami-71ca9114"
},
"us-west-1": {
"AMALINUX": "ami-de347abe"
},
"us-west-2": {
"AMALINUX": "ami-b04e92d0"
},
"ca-central-1" : {
"AMALINUX" : "ami-eb20928f"
},
"eu-west-1": {
"AMALINUX": "ami-d41d58a7"
},
"eu-central-1": {
"AMALINUX": "ami-0044b96f"
},
"eu-west-2" : {
"AMALINUX" : "ami-bfe0eadb"
},
"ap-southeast-1": {
"AMALINUX": "ami-7243e611"
},
"ap-southeast-2": {
"AMALINUX": "ami-55d4e436"
},
"ap-northeast-2": {
"AMALINUX": "ami-a04297ce"
},
"ap-northeast-1": {
"AMALINUX": "ami-1a15c77b"
},
"ap-south-1": {
"AMALINUX": "ami-cacbbea5"
},
"sa-east-1": {
"AMALINUX": "ami-b777e4db"
}
},
"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": {"Fn::FindInMap" : ["InstanceSize", {"Ref" : "EnvironmentSize"}, "DB"]},
"DBName": {"Ref" : "DatabaseName"},
"Engine": "MySQL",
"MasterUsername": {"Ref" : "DatabaseUser"},
"MasterUserPassword": {"Ref" : "DatabasePassword"}
}
},
"EC2": {
"Type": "AWS::EC2::Instance",
"Properties": {
"ImageId": {"Fn::FindInMap" : ["RegionMap", {"Ref" : "AWS::Region"}, "AMALINUX"]},
"InstanceType": {"Fn::FindInMap" : ["InstanceSize", {"Ref" : "EnvironmentSize"}, "EC2"]},
"KeyName" : "AdvancedCFN",
"UserData" : {"Fn::Base64" : {"Fn::Join" : ["", [
"#!/bin/bash", "\n",
"yum install httpd php mysql php-mysql -y", "\n",
"yum update -y", "\n",
"chkconfig httpd on", "\n",
"service httpd start", "\n",
"cd /var/www/html", "\n",
"wget https://wordpress.org/latest.tar.gz", "\n",
"tar -zxvf latest.tar.gz --strip 1", "\n",
"rm latest.tar.gz", "\n",
"cp wp-config-sample.php wp-config.php", "\n",
"sed -i 's/database_name_here/", {"Ref" : "DatabaseName"}, "/g' wp-config.php", "\n",
"sed -i 's/localhost/", {"Fn::GetAtt" : ["DB", "Endpoint.Address"]}, "/g' wp-config.php", "\n",
"sed -i 's/username_here/", {"Ref" : "DatabaseUser"}, "/g' wp-config.php", "\n",
"sed -i 's/password_here/", {"Ref" : "DatabasePassword"},"/g' wp-config.php", "\n"
]]}}
}
},
"S3": {
"Type": "AWS::S3::Bucket"
}
}
}