As a DO OPS engineer, it is very important to master at least one cloud provider. Cloud services facilitates storage, data migration, and CI/CD workflows and helps make these tasks easier and efficient.
If you need the basic introduction of cloud computing, an early -friendly tutorial for you is: What is cloud computing? A leader for early people.
In this guide, I show you how to create AWS EC2 example. This is one of the top services of AWS to build applications. By the end of this guide, you will know how to launch AWS EC2 for example and connect it to the VS code.
The table of content
Provisions
Before starting, make sure you have:
-
An AWS Account. If you don’t have one, Sign up here.
-
A gut hub repository with your source code. If you do not have a gut hub account, Sign up here.
-
The basic knowledge of web development and version control.
-
A code editor. For this tutorial, I’m using the VS code.
Let’s jump straight!
What is AWS EC2 example?
AWS EC2 (Flexible Computer Cloud) allows you to operate virtual machines in the cloud. These computer allow you to run your applications without the need for physical hardware.
Many things you can do with AWS EC2, such as hosting websites or apps, running Big Data or machine learning tasks, creating a testing environment, and handling tasks to handle essential, expanding computing power needs.
Why connect your AWS EC2 example to the VS code?
Adding your AWS EC2 example to the VS code is helpful for many reasons. Before we start the setup process, it is important to learn why it is beneficial.
-
The use of VS code provides a familiar and efficient development. It feels like coding on your own machine.
-
You don’t have to log in to your AWS EC2 example every time. You can edit the files, run commands, and do the debug codes from afar.
-
You can smooth your workflow with a built -in terminal access and extension. In this way, you will not need to switch between the SSH client all the time.
-
You can push the changes into the gut hub. Working together and is deployed very smooth.
-
The VS code works well with Java, Node JS, and Azigar. It supports many languages and framework, so it is great for cloud growth.
Now when you understand the benefits, let’s go ahead to establish a connection.
How to launch and connect your AWS EC2 example from the VS code
To launch the EC2 example on AWS, just follow these steps:
Step 1: Create AWS EC2 example
First, log into your AWS account. Then, use the search bar to find EC2 and select it.
Click EC2 and follow the on -screen instructions to create a new example.
-
Choose an AMI (Amazon Machine Image): It is a pre -formulated template that includes the operating system and can come with additional software.
-
Choose an example type: Choose the right size for your needs. For example,
t2.micro
There is a good option for early and small workloads. -
Create your EC2 example: Set up networking, storage, security groups, and other options based on your needs.
-
Launch your example: Start your virtual server and access it from afar to start using it.
Examples are running:
So what is happening in Step 1?
By launching AWS EC2, you are setting a remote server in the cloud. The AWS offers different AMIS that acts as a prepaid environment.
Step 2: Connect the AWS EC2 example to your Code Editor
You need SSH to connect your EC2 example created in AWS with your VS code.
What is SSH?
SSH (Secure Shell) is a safe way to connect and communicate with other devices. It protects your contact. This is important when you access servers or reservoirs. In the gut, you can use SSH instead of HTTPS to clone the reserves with a safe connection.
Why is SSH necessary here?
With SSH, you can connect your local code editor (such as the VS code) with your AWS EC2 example. This allows you to work directly from your editor to the EC2 for example storing files as if it is on your local computer.
To connect your AWS EC2 example to your local editor using SSH, follow these steps:
-
Open your terminal.
-
Where to go to your folder
.pem
The key file. The key file (.PEM) is automatically downloaded when you create your EC2 example (usually in the download folder). -
Update the file permits to keep your key safe and ensure appropriate verification.
For Linux users, use this command to update file permissions:
chmod 400 codebuild-keypair.pem
First of Windows users, you will first need to find your laptop username, as you will need it to update the file permission.
To do this, open your terminal and type:
whoami
It will disclose your current username.
Once your username is, use the following command to update file permissions:
icacls "codebuild-keypair.pem" /reset
icacls "codbuild-keypair.pem" /grant:r "%USERNAME%:R"
icacls "codebuld-keypair.pem" /inheritance:r
I mean: my username IjeonSo you should take this place Username of your laptop And Own Key, with which ends .pem
Growth
File permissions are updated by running this command above. So with that, you can work with your remote server.
Now that you have compiled the file permissions, you can use the SSH command with the IPV4 address to connect our EC2 example. Type the following command:
ssh -i (PATH TO YOUR .PEM FILE) ec2-user@(YOUR PUBLIC IPV4 DNS)
Example:
ssh -i "C:\Users\ijeon\OneDrive\Desktop\devops-series-nextwork\codebuild-keypair.pem" ec2-user@ec2-35-178-142-201.eu-west-2.compute.amazonaws.
Break it:
-
ssh
: This starts a safe remote connection. -
-i "C:\Users\ijeon\...\codebuild-keypair.pem"
: It tells SSH to use.pem
Key file for safe access. -
ec2-user@ec2-35-178-142-201.eu-west-2.compute.amazonaws.com
:
This command logs you into your EC2 example from your computer. Then it uses the key (.pem
File) Instead of a password for security. It also allows you to control the EC2 from your terminal as if you are using it directly.
If everything is arranged correctly, a “success message” will appear. This confirms that you have logged in and can access the remote server.
Step 3: Install programming language
Now that you have attached your example to the editor, you can install packages needed to create your web app. You can use any programming language that you feel relieved, but we will use Java for this tutorial. It will be a simple web application – we don’t have to go into modern details.
1. Install Java
In your terminal, run the following commands to install Java:
sudo dnf install -y java-1.8.0-amazon-corretto-devel
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-amazon-corretto.x86_64
export PATH=/usr/lib/jvm/java-1.8.0-amazon-corretto.x86_64/jre/bin/:$PATH
It installs Java on your system. You also need me. It helps to handle Java projects and create templates for web applications.
2. Install Maon
Maun helps you manage Java projects. It also facilitates you to create templates for web applications. Run these commands to install Mayon:
wget https://archive.apache.org/dist/maven/maven-3/3.5.2/binaries/apache-maven-3.5.2-bin.tar.gz
sudo tar -xzf apache-maven-3.5.2-bin.tar.gz -C /opt
echo "export PATH=/opt/apache-maven-3.5.2/bin:$PATH" >> ~/.bashrc
source ~/.bashrc
This command to confirm the correct installation of Maon, run this command:
mvn -v
Also, run the following command to check whether you have installed Java:
java -version
Now that you have installed Maon, you can use it to create a Java Web app with the following command:
mvn archetype:generate \
-DgroupId=com.nextwork.app \
-DartifactId=nextwork-web-project \
-Dpackage=com.nextwork.app \
-DarchetypeArtifactId=maven-archetype-webapp \
-DarchetypeVersion=1.4 \
-DinteractiveMode=false
Running the above command creates a template for your request. In the terminal, it should show a message of “success”. That means setup worked.
Step 4: Open a remote window
Now that you have installed the necessary packages and compiled your app template, you need to open your IDE or code editor. This will give you access to the folders on your remote server.
In your terminal, click on the double arrow icon to the bottom left.
When you click on it, it opens a modal window for you.
A window will appear. Click “Contact the host” which will open another window.
Then select “Add New SSH Host” to open the SSH connection terminal.
Input your SSH command to create the host.
After pressing “Inter”, a configuration file will open. In this file, make sure .pem
File and IP4v DNS
Your EC2 example addresses are correct.
A GIF view of the above image is:
The Configure File This is:
Go back to your editor and click again on this double arrow. It will automatically open a new window.
If your editor shows the IPV4 DNS address, your VS code is successfully linked to the EC2 example.
Now that you are connected and a new window has opened, let’s access the secure folder in the cloud.
Step 5: Get access to your Project Folder
In Step 3, remember when did you install Maon? It created a template for your web app. Now, you will access the folder where you have created it.
-
Go to the Explorer panel in the window.
-
Click on “Open folder“ Button
Clicking this button opens a modal box to select your folder, which was developed by the Maon Template:
Click on the Template File access “,” SRC “folder. It takes you index.jsp
File
With the formation of this template, you can decide to comply and send it to your own gut repository for storage.
Conclusion
Great work! You have set the AWS EC2 example, connected it to your code editor, and installed the tools required for your web app. In this tutorial, we used Java, but you can also select other languages such as Node Dot J or Azigar.
If you find this article helpful, please share it with others that may find it interesting.
Be updated with my projects by following me TwitterFor, for, for, for,. Linked And Got hub.
Thank you for reading.
Unlock Your Business Potential with Stan Jackowski Designs
At Stan Jackowski Designs, we bring your ideas to life with cutting-edge creativity and innovation. Whether you need a customized website, professional digital marketing strategies, or expert SEO services, we’ve got you covered! Our team ensures your business, ministry, or brand stands out with high-performing solutions tailored to your needs.
🚀 What We Offer:
- Web Development – High-converting, responsive, and optimized websites
- Stunning Design & UI/UX – Eye-catching visuals that enhance engagement
- Digital Marketing – Creative campaigns to boost your brand presence
- SEO Optimization – Increase visibility, traffic, and search rankings
- Ongoing Support – 24/7 assistance to keep your website running smoothly
🔹 Take your business to the next level! Explore our outstanding services today:
Stan Jackowski Services
📍 Located: South of Chicago
📞 Contact Us: https://www.stanjackowski.com/contact
💡 Bonus: If you’re a ministry, church, or non-profit organization, we offer specialized solutions, including website setup, training, and consultation to empower your online presence. Book a FREE 1-hour consultation with Rev. Stanley F. Jackowski today!
🔥 Looking for a done-for-you autoblog website? We specialize in creating money-making autoblog websites that generate passive income on autopilot. Let us handle the technical details while you focus on growth!
📩 Let’s Build Something Amazing Together! Contact us now to get started.