Python script to automatically install Wordpress in an AWS EC2 instance This script has only be tested on Debian and Windows 10 ! Be carrefull when use it on others systems.
To use this script you need to install Python3 and pip3.
- On debian/ubuntu :
apt-get install python3 pip3
- On centos :
yum install python3 pip3
- On Windows : install the last 3.X version on : https://www.python.org/downloads/
In the installation, be carrefull to select the option Add Python to environnment variables
After install Python3 and pip3, please install theses librairies : boto3
, paramiko
and requests
. (pip3 install boto3 paramiko requests
on your command line)
To use this script, you need (obviously) an Amazon AWS account.
Then, you have to create a key pair. Keep it name in mind. You'll need it in to run the program. (How to create a key pair on EC2 : (https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-key-pairs.html)
After that, you'll need to create a User and get AWS Access ID and Secret Key. To do that :
-
Launch the Identity and Access Management console (IAM) in AWS.
-
Click Users on the navigation menu on the left of the screen.
-
In the popup window, click on Add User.
- In the new window, provide a user name and choose the 'Programmatic Access' access type, then click next.
- To set the permissions, choose 'Attach Existing Policies Directly' and in the Policy Filter type 'AmazonEC2FullAccess', you can choose any permission level, but in this example I'll click on the checkbox next to 'AmazonEC2FullAccess'. Then repeat this step with 'AmazonSNSFullAccess' and then click the 'next' button.
-
Finally, review the user and permission levels, and click on the 'Create User' button.
-
The next page will show your keys, as shown below. These are only available once, so it its a good idea to download and save then safely in a secure location.
(credits to https://blog.ipswitch.com/how-to-create-an-ec2-instance-with-python for this tutorial and pictures)
When that was done, you have to edit the script variables.py
with your own informations.
Finally you can run the script by using : python3 program.py
or python program.py
in Windows.
This script will create Amazon EC2 instance(s). Be carrefull, it can cost you money !
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request