Configuring an AWS Instance using the user data field

Darius M
3 min readDec 19, 2022

--

Create a t2.micro EC2 instance with the OS of your choice and install NGINX:

  1. Sign in to the AWS Management Console and navigate to the EC2 dashboard.

2. Click the “Launch Instance” button to start creating a new EC2 instance.

3. Select the AMI (Amazon Machine Image) that corresponds to the OS you want to use. You can choose from a variety of pre-configured AMIs, including various versions of Linux, Windows, and more. Make sure to choose an AMI that is eligible for the free tier. (I’ll be using Amazon Linux)

4. Select the t2.micro instance type, which is eligible for the free tier.

5. make sure you either create a a security key or use and existing one.

On the “Configure Instance Details” page, scroll down to the “Advanced Details” section. In the “User data” field, enter a script that updates all packages, installs NGINX, and starts the NGINX service. You can use a script like this: (there are multiple script variations that will work because we are using Amazon linux in this case, if you use another OS you’ll have to use a script suited for that operating system)

#!/bin/bash
sudo yum update -y
sudo amazon-linux-extras install epel -y
sudo amazon-linux-extras install nginx1 -y
sudo amazon-linux-extras enable nginx1
sudo systemctl start nginx

Once the instance is launched, you can find its public IP address in the EC2 dashboard.

To verify that NGINX has been installed, you can use a web browser to access the public IP address of the instance. You should see the default NGINX web page.

Thats all for this walk through!!

--

--

Darius M

Cloud Engineer ☁️ IT Specialist| Linux | Dev Ops Enthusiast Nerdy about all things self improvement and Crypto.