Hands-On: Run an Application Through the AWS CLI
Learn to run a WordPress EC2 instance through the AWS CLI.
Let’s recap what we did in the last chapter when creating a WordPress EC2 instance through the AWS console.
- Find a suitable WordPress AMI on the AWS Marketplace.
- Launch an EC2 instance with this AMI.
- Connect to it through its public IP or public DNS.
Now, we will recreate these steps through the AWS CLI instead of using the AWS Console.
Decode the AWS CLI command to create an EC2 instance
Let’s take a look at the command to run an EC2 instance from the CLI:
By the way, we can format commands over multiple lines by using the backslash (\) to split up the command:
This should be pretty straightforward because this command only has three lines:
- The
aws ec2 run-instancesstatement containing theec2command and therun-instancessubcommand. - The
-image-idparameter to specify the AMI image (essentially containing the operating system and software to run). - The
--instance-typeparameter to specify the instance type. The instance type refers to the specifications of the virtual server. Here, we’ll uset2.micro.
We’ll go into more detail regarding AMIs and instance types later in this course when taking a deeper look at EC2.
These are the only required parameters to run an EC2 instance, but let’s add another one to ...