Showing posts with label EC2. Show all posts
Showing posts with label EC2. Show all posts

Tuesday, 3 September 2024

How to Set Up and Use Amazon AWS CLI on Windows/Mac/Linux | AWS CLI Installation and Basic Usage

Ready to Level Up Your Cloud Skills? ☁️

Don't miss out on more AWS and Java tutorials. Join our growing community today!

👉 SUBSCRIBE TO RAM N JAVA

Introduction

The AWS Command Line Interface (CLI) is a unified tool that allows you to manage your AWS services from the terminal. Instead of clicking through the AWS Management Console, you can run powerful commands to automate your workflows and manage resources like S3, EC2, and SQS efficiently.

Step 1: Installing AWS CLI

Depending on your operating system, follow the steps below:

Windows

  • Download the AWS CLI MSI Installer from the official AWS website.
  • Run the installer and follow the "Next" prompts until finished.

macOS

brew install awscli

Linux

curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install

Step 2: Configuring Your Credentials

Once installed, you need to link the CLI to your AWS account. First, create an IAM User in the AWS Console to get your Access Key and Secret Key. Then, run:

aws configure

Provide the following when prompted:

  • AWS Access Key ID
  • AWS Secret Access Key
  • Default region name (e.g., us-east-1)
  • Default output format (e.g., json)

Step 3: Essential AWS Commands

Amazon S3 (Storage)

List all your buckets:

aws s3 ls

Create a new bucket:

aws s3 mb s3://my-unique-bucket-name

Amazon EC2 (Servers)

List your running instances:

aws ec2 describe-instances

Amazon SQS (Queues)

Create a simple message queue:

aws sqs create-queue --queue-name MyQueue

Conclusion

Mastering the AWS CLI is a game-changer for cloud engineers. It allows for faster management, easy scripting, and powerful automation. Start practicing these commands today to streamline your cloud operations!

Friday, 6 May 2022

How to Update Server Software Packages and Install JDK or Java in AWS EC2 Instance?

🚀 Become a Cloud Expert!

Subscribe to Ram N Java for the best AWS and Java tutorials.

SUBSCRIBE NOW

Overview

Setting up a new Amazon EC2 instance often requires two immediate steps: ensuring all system software is up to date and installing the Java Development Kit (JDK). In this tutorial, we will use the YUM package manager to update our Linux environment and install Java 8.

Step 1: Connect to Your EC2 Instance

Before running commands, you must connect to your instance. Use your terminal or a tool like PuTTY with your public IPv4 address and your private key (.pem file).

Step 2: Update Software Packages

It is crucial to start with the latest security and software patches. Run the following command to update your system:

sudo yum update

If your system is already up to date, the terminal will let you know. If not, press 'y' when prompted to proceed with the updates.

Step 3: Check for Existing Java Installation

To see if Java is already installed, run:

java -version

If you see a message saying "command not found," you are ready to install a new version.

Step 4: Search and Install Java (JDK 8)

First, list the available Java packages in the repository:

yum list java*

Once you see java-1.8.0 in the list, install it using:

sudo yum install java-1.8.0

Step 5: Verify the Installation

After the process completes, verify that Java is correctly configured:

java -version

You should now see output similar to openjdk version "1.8.0_xxx".

Conclusion

Your EC2 instance is now updated and equipped with Java 8. This provides a solid foundation for running Java applications or setting up a web server. Happy coding!

How to Connect to an EC2 instance on AWS using WinSCP? | SpringBoot-Deploying to AWS EC2 Instance

🚀 Master AWS & Java Today!

Subscribe to Ram N Java for more easy-to-follow cloud deployment tutorials.

SUBSCRIBE ON YOUTUBE

Introduction

WinSCP is a popular, free SFTP and FTP client for Windows. It provides a powerful graphical interface for transferring files between your local computer and a remote server, such as an Amazon EC2 instance. In this guide, we'll walk through installing WinSCP and configuring it to securely access your AWS instance.

Step 1: Download and Install WinSCP

Visit the official WinSCP website and download the installer. Follow the setup instructions. During installation, if you are asked to import sessions from PuTTY, you can choose "No" to start with a fresh configuration.

Step 2: Get Your EC2 Connection Details

Log in to your AWS Management Console and navigate to the EC2 Dashboard. Select your running instance to find the following information:

  • Public IPv4 Address: (or Public DNS name) to be used as the Host Name.
  • User Name: Typically ec2-user for Amazon Linux or ubuntu for Ubuntu instances.

Step 3: Configure Authentication (PPK File)

WinSCP uses the SSH protocol, which requires your private key for authentication. If you have a .pem file from AWS, WinSCP can automatically convert it to a .ppk file:

  1. Open WinSCP and click on Advanced.
  2. Under the SSH section, click on Authentication.
  3. Browse and select your .pem file. WinSCP will offer to convert it; click "OK" and save the new .ppk file.

Step 4: Login and Transfer Files

With the Host Name, User Name, and Key file configured, click Login. Once connected, you will see your local files on the left and your EC2 server files on the right. You can now drag and drop files to transfer them instantly!

Conclusion

You have successfully connected to your AWS EC2 instance using WinSCP. This setup is essential for deploying applications, managing server configurations, and handling logs. Keep practicing and explore the advanced features of WinSCP to speed up your workflow!

How to Connect to an EC2 instance on AWS via SSH? | SpringBoot-Deploying to AWS EC2 Instance

🚀 Mastering the Cloud?

Join the Ram N Java community for high-quality AWS and Spring Boot tutorials!

SUBSCRIBE TO THE CHANNEL

Introduction

Connecting to an Amazon EC2 instance via SSH is a critical skill for any developer or DevOps engineer. Whether you're deploying a Spring Boot application or managing a server, SSH allows you to securely access your Linux machine from anywhere. In this guide, we'll walk through the entire process using an intermediate Linux machine and a .pem key file.

Step 1: Prepare Your Key File (.pem)

When you first launch an EC2 instance, AWS provides a .pem file (private key). You must have this file to authenticate your connection. If you are using a Linux machine to jump into another EC2 instance, follow these steps:

  • Open WinSCP or any file transfer tool.
  • Upload your .pem file to the Linux machine you are currently logged into.
  • Verify the file exists by running the ls command in your terminal.

Step 2: Secure Your Key File

SSH requires that your private key file is not publicly viewable. If the permissions are too open, the connection will be rejected. Run the following command to set the correct permissions:

chmod 400 your-key-file.pem

Step 3: Get Connection Details from AWS

To connect, you need the Public DNS or IP address of your instance:

  1. Go to the AWS EC2 Console.
  2. Select your running instance and click Connect.
  3. Under the SSH Client tab, copy the example command provided by AWS.

Step 4: Execute the SSH Command

Using the details from AWS, run the SSH command in your terminal. The structure looks like this:

ssh -i "your-key-file.pem" ec2-user@your-public-dns-name

Once you hit Enter, you'll be securely logged into your Amazon EC2 instance!

Conclusion

Congratulations! You've successfully connected to your AWS EC2 instance via SSH. This foundation allows you to install software, manage files, and deploy applications like Spring Boot with ease. Remember to keep your .pem files secure and never share them publicly!

How to Connect to an EC2 instance on AWS using PUTTY? | SpringBoot-Deploying to AWS EC2 Instance

🚀 Master Cloud Deployment!

Want more AWS and Spring Boot tutorials? Subscribe to Ram N Java today!

SUBSCRIBE ON YOUTUBE

Introduction

Connecting to an Amazon EC2 instance from a Windows machine typically requires a tool called PuTTY. Since AWS provides private keys in .pem format and PuTTY uses .ppk, you'll also need the PuTTY Key Generator (PuTTYgen). In this guide, we'll walk through the entire conversion and connection process.

Step 1: Install PuTTY and PuTTYgen

Download the PuTTY installer for Windows from the official website. This installer usually includes both the PuTTY client and PuTTYgen. Complete the installation before proceeding to the next step.

Step 2: Convert .pem to .ppk using PuTTYgen

AWS gives you a .pem file, but PuTTY needs a .ppk file. Here is how to convert it:

  1. Open PuTTYgen.
  2. Click Load and select your .pem file (ensure "All Files" is selected in the file browser).
  3. Once loaded, click Save private key.
  4. Give it a name and save it as a .ppk file.

Step 3: Get Your EC2 Connection Details

Log in to your AWS Console and go to the EC2 Dashboard:

  • Ensure your instance is Running.
  • Copy the Public IPv4 address or Public IPv4 DNS.
  • Note the default username (usually ec2-user for Amazon Linux).

Step 4: Configure the PuTTY Connection

  1. Open PuTTY.
  2. In the Host Name field, paste your IP address or DNS.
  3. Go to Connection > Data and enter your username (e.g., ec2-user) in the "Auto-login username" field.
  4. Go to Connection > SSH > Auth, click Browse, and select your .ppk file.
  5. Go back to Session, give it a name (like "My-EC2"), and click Save.

Step 5: Connect and Verify

Click Open. If a security alert pops up, click "Yes." You should now be logged into your AWS EC2 terminal!

Pro Tip: Remember that stopping and starting your instance changes its Public IP address unless you are using an Elastic IP!

Conclusion

You have successfully configured PuTTY to access your AWS environment. This setup is the gateway to deploying applications, managing databases, and exploring the power of the cloud. Stay tuned for more tutorials on Spring Boot deployment!

How to Create EC2 Instance in AWS? | What is Amazon EC2? | SpringBoot-Deploying to AWS EC2 Instance

🚀 Ready to Launch Your Apps?

Master the cloud with Ram N Java. Subscribe for more expert AWS and Spring Boot tutorials!

SUBSCRIBE ON YOUTUBE

Introduction

Deploying a Spring Boot RESTful service in the cloud is a game-changer. Unlike a local setup, an Amazon EC2 (Elastic Compute Cloud) instance provides a public IP address, allowing your APIs to be accessed from anywhere in the world. In this tutorial, we will walk through the process of launching your own Linux server on AWS.

Step 1: Sign Up and Access EC2

First, create an AWS account at aws.amazon.com. Once logged in, search for EC2 under the "Compute" services category. Before launching, ensure you select the Region (e.g., US East N. Virginia) that is closest to your target audience for the best performance.

Step 2: Choose an Amazon Machine Image (AMI)

An AMI is a template that contains your operating system and software. For beginners, it is highly recommended to select the Amazon Linux 2 AMI. Look for the "Free Tier Eligible" label to avoid unnecessary costs during your first year.

Step 3: Choose Instance Type and Configure

  • Instance Type: Select t2.micro (1 vCPU, 1 GB Memory) to stay within the Free Tier.
  • Configure Details: Enable Termination Protection to prevent your server from being deleted by mistake.
  • Add Storage: The default is 8 GB, but Free Tier users can increase this up to 30 GB.
  • Add Tags: Add a "Name" tag (e.g., Spring-Boot-Server) to easily identify your instance.

Step 4: Configure Security Groups

Security groups act as a firewall. To run a Spring Boot application, you need to open specific ports:

  • SSH (Port 22): For remote access.
  • HTTP (Port 80) & HTTPS (Port 443): For web traffic.
  • Custom TCP (Port 8080): The default port for Spring Boot/Tomcat.

Step 5: Create a Key Pair & Launch

Before launching, AWS will ask you to create a Key Pair. Download the .pem file and keep it secure—you will need this to connect to your server from your computer. Click Launch Instances and wait for the status to change to "Running."

Managing Your Instance

You can Stop your instance when you're not using it to save on credits, or Terminate it if you want to delete the server entirely. Once running, you'll see a Public IPv4 Address—this is your gateway to the world!

Conclusion

You have successfully launched a Linux server in the cloud! This is the first step toward hosting powerful Java applications on AWS. In our next guide, we will connect to this instance and deploy our code. Happy cloud computing!

Tutorials