Deploy a WordPress Blog in AWS with Chef (DevOps/Cloud Automation — Part II)

Iyana Garry
5 min readMar 26, 2019

My last tutorial focused on deploying with Terraform. This tutorial will be focused on deploying with Chef.
Like Terraform, Chef is software that involves infrastructure automation. We will deploying Wordpress again.

1. Download Chef server.

To get the latest version of Chef server, copy the link from the software’s website.

I used the “wget -P” command to download the software to my “Downloads” directory.

2. Install Chef server.

This warning message that I received, I believe is related to the fact the software was co-signed with the SHA-256 algorithm instead of the DSA/SHA-1 algorithm.

3. Start Chef server.

4. Configure the Chef server URL.

This software installs the web interface for the Chef server. This will be needed to configure the URL for your local Chef server.

This command starts the software for the GUI and accepts the agreement license so that the software can start.

This command creates an admin account and SSH key for your server.
This is the format of the command:
sudo chef-server-ctl user-create [username] [first name] [last name] [email address] [password] -f [file path and SSH key]

This command creates the URL for your server. The server will be named after the short name of your organization.
This is the format of the command:
sudo chef-server-ctl org-create [short name of organizaton] [long name of organization] — association_user [username] — filename [full path of an SSH key]
If you’re not working for an actual organization, you can just make one up like I did.

5. Install Chef Development Kit.

Chef Development Kit will be needed to install a command-line tool called Knife. Knife is the tool that will connect the Chef server to your AWS credentials, which will be configured later.

The configuration of Knife is why we needed to install the Chef GUI and configured the Chef server URL.

6. Download AWS CLI

If you’re using RHEL 7 like I am, you can follow the steps above to install PIP and the AWS CLI. Like I mentioned in my previous tutorial, the AWS CLI cannot be installed in a straightforward way in Red Hat. You need to install EPEL and PIP (Python 2 is pre-installed in Red Hat.)

7. Enter AWS credentials

Log into the AWS dashboard (console.aws.amazon), click on your username, click on “My Security Credentials”. You will see your AWS access key. To get the secret key, you have to download it, but it can only be downloaded once and that’s when you configured access key/secret key pair for the first time. If you do not have access to this download, then you need to create another access key/secret key pair.

The “aws configure” command will open the file where you will enter the AWS access key/secret key pair.

8. Create an AWS SSH key

This command is used to create an SSH key to connect to the EC2 instance that you will be creating.
With this command, you will enter a name and full path for the SSH key.

This is the command that will create the live site.
This is the format of the command:
knife ec2 server create — image ami-0dccf86d354af8ce3 — flavor [size of the EC2 instance] — ssh-key [name of the SSH key] — region [AWS region]
Note #1: The image, ami-0dccf86d354af8ce3, is the image that will install and run Wordpress in the EC2 instance.
Note #2: The public IP address in the output above is the IP address of the site. Copy the address and paste it in the URL bar of your browser.

View Part I of this tutorial series on WordPress blog deployment with Terraform.

View Part III of this tutorial series on WordPress blog deployment with Ansible.

View Part IV of this tutorial series on WordPress blog deployment with Docker.

--

--