How to create CloudFormation template for setting up WordPress on one instance and MySQL on another EC2 instance?
I used this part for MySQL, but doesn’t work, please give a suggestion… thank you.
"DatabaseServer" : {
"Type": "AWS::EC2::Instance",
"Metadata" : {
"AWS::CloudFormation::Init" : {
"config" : {
"packages" : {
"yum" : {
"mysql" : [],
"mysql-server" : [],
"mysql-devel" : [],
"mysql-libs" : []
}
}
},
"services" : {
"sysvinit" : {
"mysqld" : { "enabled" : "true", "ensureRunning" : "true" }
}
}
}
},
AWS CloudFormation offers a large list or sample AWS CloudFormation Templates, which you can start/test easily from the AWS Management Console. There are several MySQL based solutions available, including a dedicated one for WordPress as well as a generic LAMP stack, in particular:
WordPress is web software you can use to create a beautiful website or blog.
A simple LAMP stack running a PHP “Hello World” application.
I recommend to explore the selected template(s) and continue from there by tailoring it to your needs, e.g. by splitting the single EC2 instance into two (though I’d highly recommend to use a solution based on an Amazon RDS for MySQL database instead, which is much more robust and easier to handle for starters, for only slightly increased cost).
To create a MySQL RDS instance with CFN you need to use the resource
AWS::RDS::DBInstance
withmysql
engine and the wantedEngineVersion
. There are some others props that you need to initialize that are not specific for MySQL Instance.You can use Altostra Designer to create the CFN template super quick.