Managing Ubuntu EC2 Developer Environment using Terraform

Building ProjectX.Cloud | GSoC'23 @ DBpedia | DevOps & Cloud Computing
Search for a command to run...

Building ProjectX.Cloud | GSoC'23 @ DBpedia | DevOps & Cloud Computing
nice
Created this Tutorial for my talk at Cloud @ DevFest Kolkata 2025 1. Objective Set up a minimal API on Google Cloud and test its performance under load using Grafana K6. 2. Prerequisites Google Cloud Account: Access to a GCP project. K6 Installed:...
An in-depth look at deploying Kafka on Kubernetes, covering Kafka features, configuration, workflows, and techniques for achieving high availability.

Tired of searching Docs and Tutorials to get your RKE cluster up and running? You are at the right spot!

Is your free 15GB of Google Drive storage full? Tired of constantly clearing storage or creating multiple Gmail accounts? I got you covered.

DBpedia Search API enhancement Project GitHub Link : https://github.com/AKSW/sante Documentation Repository Link : https://github.com/AKSW/sante-api-docs This project took place over the summer of 2023 as part of the Google Summer of Code, working wi...

I made an IAM user through my Root account in AWS. In addition, I stored the credentials in aws-vault which helps to execute commands faster and user-specific. Then, I installed Docker and Terraform in my local system Finally, deployed an EC2 using Terraform
Setup MFA (Multi Factor Authentication) for root user [Mandatory]
Clicked on Reveal Pin to get Token (refreshes every 30 second)
Create User
Displays the Credentials (Download the .csv file or copy and store the credentials in a safe location, This is will not be displayed again)

aws-vault add [user-id]
aws sts get-caller-identity
aws-vault list --> (Lists user)
aws-vault add [user-id] --> (Adds more user)
cat ~/.ssh/id_rsa.pub
Copy the Key Content
If its not found, go to the same location and Generate SSH Key using the following Command :
ssh-keygen -t rsa
Key PairsActions and then Import Key Pair
vi ~/.aws/config
[profile ronitblenz]
region=ap-south-1
mfa_serial=arn:aws:iam::22224xxxxxxx:mfa/[IAM-USER_NAME]
Create a docker-compose.yaml file and paste the following snippet :
version: '3.7'
services:
tf:
image: hashicorp/terraform:0.12.24
volumes:
- .:/infra
working_dir: /infra
environment:
- AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}
- AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}
Create a main.tf file and paste the following snippet :
provider "aws" {
region = "us-east-1"
version = "~> 2.61.0"
}
resource "aws_instance" "web" {
ami = "ami-052efd3df9dad4825"
instance_type = "t2.micro"
key_name = "finalkey"
security_groups = [aws_security_group.web.name]
tags = {
Name = "WebServerByTf"
}
}
resource "aws_security_group" "web" {
name = "web-security-group"
description = "Allow access to our web server"
ingress {
description = "Allow SSH"
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
}
output "instance_public_dns" {
value = aws_instance.web.public_dns
}
Turn on the Docker Daemon in Background (Else, the following commands will not be executed)
Initiate the Terraform Build
docker-compose run --rm tf init
Shows the Tasks which are about to happen if the Terraform build is executed
docker-compose run --rm tf plan
Execute the Terraform Build
docker-compose run --rm tf apply
Type "yes" if asks for confirmation
And, you have successfully created an EC2 Ubuntu instance over AWS using Terraform This can be used as a Testing Environment by Developers or Cloud Engineers.

Here is the GitHub Repository Link

Up and running Ubuntu Environment over AWS EC2 using Terraform
Follow me on Twitter, LinkedIn and GitHub for more amazing blogs about Cloud, DevOps and More !