Creating a t2.micro EC2 Instance and Installing NGINX
Objective: (Doing all of this through the AWS CLI)
- Create a t2.micro EC2 instance with the OS of your choice (Just make sure it is free tier).
- In the user-data field, use a script that updates all packages, installs NGINX, and start the service.
- Verify that the instance has the NGINX webserver downloaded and installed through the public IP.
First lets go over what is:
Amazon Web Services (AWS) is a complete cloud computing platform that consists of infrastructure as a service (IaaS) and platform as a service (PaaS) offerings. AWS provides scalable answers for compute, storage, databases, analytics, and more.
The AWS Command Line Interface (AWS CLI) is a unified tool to manage your AWS services. With just one tool to download and configure, you can control multiple AWS services from the command line and automate them through scripts.
NGINX is open supply software program for internet serving, opposite proxying, caching, load balancing, media streaming. It commenced out as an internet server designed for max overall performance and stability.
Step 1: You will need to do is to create an Amazon Management Console account, https://aws.amazon.com/premiumsupport/knowledge-center/create-and-activate-aws-account/
After this has been completed you will need to set up your AWS CLI, for instructions and more information visit (https://docs.aws.amazon.com/polly/latest/dg/setup-aws-cli.html)
Step 2: Lets launch an t2.mirco EC2 Instance:
Log into your AWS account
Next click on EC2 (you can also use the search bar)
Name your instance
Next you will choose an Application and OS Image (Amazon Machine Image) I will be using Amazon Linux for this project,
Now let choose and instance type always go for the t2.micro (free tier eligible)
You will need to create your key pair or use an existing key pair.
Now lets go to Network settings (see picture below and use these settings)
User Data enter in this script:
Now let launch this instance
Step 3: Open up your command prompt
What is the Command Prompt? In Windows operating systems, the Command Prompt is a program that emulates the input field in a text-based user interface screen with the Windows Graphical User Interface (GUI). It can be used to execute entered commands and perform advanced administrative functions.
At the command prompt you will need to ssh in since you are using Linux, you will need to find your ssh information from the instance you just launched.
Type in the command prompt: aws configure
You will need to your access key id, secret access key, your default region name (choose the closes region to you) and default output format (we will be using json on this project).
Type in the command prompt: aws ec2 list-instances
Type in the command prompt: aws describe-instance ( information about your ec2 instance)
Final command is: chmod +x nginx_script.sh
Now go back to your AWS console under your instance and locate your public IP address and now copy this into your url and you should get this
All done!