In Day 1 – Session 2, I continued my AWS learning by working with Amazon EC2, Nginx, Amazon S3, AWS CLI, and AWS Lambda.
1. Create an EC2 Instance
The first task was to create an Amazon EC2 instance.
EC2 (Elastic Compute Cloud) provides virtual servers that can be used to run applications and services in AWS.
Steps
- Log in to the AWS Management Console.
- Search for EC2.
- Click Launch instance.
- Enter a name for the instance.
- Select the required AMI.
- Select the required instance type.
- Create or select a key pair.
- Configure the network and security group settings.
- Launch the instance.
After completing these steps, the EC2 instance was successfully created and started.
2. Connect to the EC2 Instance
After launching the instance, I connected to it using SSH.
For an Ubuntu-based EC2 instance, the command is:
ssh -i "your-key.pem" ubuntu@<EC2-PUBLIC-IP>
After successfully connecting, I was able to access the EC2 server through the terminal.
3. Install Nginx
Next, I installed Nginx on the EC2 instance.
Nginx is a web server that can be used to serve websites and web applications.
For an Ubuntu-based instance, I used:
sudo apt update
Then I installed Nginx:
sudo apt install nginx -y
After installation, I started the Nginx service:
sudo systemctl start nginx
I also enabled Nginx to start automatically when the server starts:
sudo systemctl enable nginx
To check the status of Nginx:
sudo systemctl status nginx
Nginx was successfully installed and running on the EC2 instance.
4. Test Nginx
After installing Nginx, I opened the public IP address of the EC2 instance in a browser.
http://<13-233-163-95>
The default Nginx welcome page was displayed successfully.
This confirmed that the EC2 instance was working as a web server.
5. EC2 and S3 Using AWS CLI
Next, I worked on transferring files between EC2 and S3 using the AWS CLI.
I practiced both directions:
EC2 → S3
S3 → EC2
This helped me understand how EC2 can interact with S3 through command-line commands.
6. Transfer a File from EC2 to S3
First, I created a test file on the EC2 instance.
strangerthings.csv
Then I uploaded the file to the S3 bucket using the AWS CLI:
aws s3 cp strangerthings.csv s3://nivi-22034-15/
The file was successfully transferred from EC2 to S3.
To verify the file in the S3 bucket:
aws s3 ls s3://nivi-22034-15/
The file was listed successfully.
The flow was:
EC2
|
| AWS CLI
v
S3 Bucket
|
└── strangerthings.csv
7. Transfer a File from S3 to EC2
Next, I tested the reverse process by downloading a file from S3 to EC2.
I used:
aws s3 cp s3://nivi-22034-15/strangerthings.csv .
The file was downloaded to the current directory of the EC2 instance.
To verify the file:
ls
To view the contents:
cat strangerthings.csv
The file was successfully transferred from S3 to EC2.
The flow was:
S3 Bucket
|
| AWS CLI
v
EC2
|
└── strangerthings.csv
8. Create an AWS Lambda Function
After working with EC2 and S3, I moved on to AWS Lambda.
AWS Lambda allows us to run code without directly managing servers.
Steps
- Open the AWS Management Console.
- Search for Lambda.
- Click Create function.
- Select Author from scratch.
- Enter the function name.
- Select the required runtime.
- Create the Lambda function.
The Lambda function was successfully created.
9. Configure an S3 Event Trigger
Next, I configured an S3 event trigger for the Lambda function.
The objective was to trigger the Lambda function whenever an object was deleted from the S3 bucket.
Steps
- Open the Lambda function.
- Go to the Function overview section.
- Click Add trigger.
- Select S3 as the trigger source.
- Select the required S3 bucket.
- Configure the event type.
- Select the Object Deleted event.
- Confirm the configuration.
- Add the trigger.
The event flow was:
S3 Bucket
|
| Object Deleted
v
AWS Lambda
|
v
Lambda Function Executes
10. Test the S3 Delete Trigger
After configuring the trigger, I tested it by deleting an object from the S3 bucket.
For example:
aws s3 rm s3://nivi-22034-15/test.txt
When the object was deleted, the S3 event triggered the Lambda function.
I then checked the Lambda logs to verify that the function was executed successfully.
This confirmed that the S3 Object Deleted event was successfully connected to the Lambda function.
11. Overall Workflow
The main workflow I implemented during this session was:
AWS
|
+----------+----------+
| |
EC2 S3
| |
| AWS CLI |
+-------------------->|
| |
|<--------------------+
| |
| Object Deleted
| |
| v
| Lambda
| |
| v
| Function Executes
12. What I Learned
In Day 1 – Session 2, I learned:
- How to create an EC2 instance
- How to connect to an EC2 instance using SSH
- How to install Nginx
- How to start and enable the Nginx service
- How to access the Nginx server using the EC2 public IP
- How to use AWS CLI from EC2
- How to transfer files from EC2 to S3
- How to transfer files from S3 to EC2
- How to create an AWS Lambda function
- How to configure an S3 event trigger
- How to trigger Lambda when an S3 object is deleted
- How to verify Lambda execution using logs
Conclusion
Day 1 – Session 2 gave me hands-on experience with EC2, Nginx, S3, AWS CLI, and Lambda.
I started by creating an EC2 instance and installing Nginx. I then used AWS CLI to transfer files between EC2 and S3.
Finally, I created a Lambda function and configured an S3 Object Deleted event trigger. After deleting an object from S3, I verified that the Lambda function was triggered successfully.
This session helped me understand how different AWS services can work together to build cloud-based applications.






Top comments (0)