Skip to content

Commit

Permalink
Create wordpressuserdata
Browse files Browse the repository at this point in the history
  • Loading branch information
ashutoshvct authored Sep 10, 2017
1 parent 3a2d81b commit 1251d04
Showing 1 changed file with 128 additions and 0 deletions.
128 changes: 128 additions & 0 deletions wordpressuserdata
Original file line number Diff line number Diff line change
@@ -0,0 +1,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"
}
}
}

0 comments on commit 1251d04

Please sign in to comment.