Posted on Leave a comment

Associate Public IP with an EC2 Instance

Here’s how to associate an Elastic IP address with an EC2 instance using AWS CLI:

Step 1: Allocate an Elastic IP address

First, allocate an Elastic IP address using the allocate-address command:

aws ec2 allocate-address --region <region>

Replace <region> with the region where you want to allocate the Elastic IP address. This command will allocate a new Elastic IP address and return the IP address in JSON format.

Step 2: Associate the Elastic IP address with your instance

Next, associate the Elastic IP address with your EC2 instance using the associate-address command:

aws ec2 associate-address --instance-id <instance-id> --public-ip <public-ip> --region <region>

Replace <instance-id> with the ID of the EC2 instance that you want to associate the Elastic IP address with, <public-ip> with the Elastic IP address that you allocated in Step 1, and <region> with the region where your EC2 instance is located.

This command will associate the Elastic IP address with your EC2 instance, making it reachable from the internet.

Step 3: Verify the association

You can verify that the Elastic IP address is associated with your EC2 instance by using the describe-instances command:

aws ec2 describe-instances --instance-ids <instance-id> --query 'Reservations[].Instances[].PublicIpAddress' --output text --region <region>

Replace <instance-id> with the ID of the EC2 instance that you associated the Elastic IP address with, and <region> with the region where your EC2 instance is located. This command will output the public IP address of your EC2 instance, which should match the Elastic IP address that you associated with it.

By associating an Elastic IP address with your EC2 instance using AWS CLI, you can add a public facing network to your instance and make it reachable from the internet.

Posted on Leave a comment

Creating KeyPairs with AWS CLI

To create a key pair using AWS CLI, you can use the aws ec2 create-key-pair command. Here’s how to do it:

Step 1: Open the AWS CLI

First, open the AWS CLI on your local machine or a remote server. You can do this by opening a terminal window and typing aws in the command prompt.

Step 2: Create a key pair

To create a new key pair, use the following command:

aws ec2 create-key-pair --key-name <key_name> --query 'KeyMaterial' --output text > <key_name>.pem

Replace <key_name> with a unique name for your key pair. This will be the name that you use to identify the key pair when launching EC2 instances.

This command will create a new key pair with the specified name and output the private key to a file with the same name as the key pair, but with a .pem extension. The private key file will be saved in the current working directory.

Step 3: Set permissions on the private key file

Before you can use the private key file to connect to an EC2 instance, you need to set the correct permissions on the file. Use the following command to set the permissions:

chmod 400 <key_name>.pem

Replace <key_name> with the name of your key pair.

Step 4: Verify the key pair

You can verify that the key pair was created successfully by using the following command:

aws ec2 describe-key-pairs --key-names <key_name>

This command will display information about the key pair, including the fingerprint of the public key.

That’s it! You have successfully created a key pair using AWS CLI. You can now use this key pair to launch EC2 instances and connect to them using SSH.

Posted on Leave a comment

How to install the Amazon AWS CLI on Linux Mint.

Before we begin, make sure that your system is up to date by running the following commands in the terminal:

sudo apt-get update
sudo apt-get upgrade

Now let’s move on to the installation process.

Step 1: Install pip

The AWS CLI requires Python and pip to be installed on your system. If you don’t have pip installed, you can install it using the following command:

sudo apt-get install python3-pip

Step 2: Install the AWS CLI

Once you have pip installed, you can install the AWS CLI using the following command:

pip3 install awscli --upgrade --user

This command will download and install the latest version of the AWS CLI.

Step 3: Verify the installation

To verify that the installation was successful, you can run the following command:

aws --version

This command will display the version number of the AWS CLI installed on your system.

Step 4: Configure the AWS CLI

After the installation is complete, you need to configure the AWS CLI to access your AWS account. To do this, run the following command:

aws configure

This command will prompt you to enter your AWS access key ID, secret access key, default region name, and default output format. You can find your access key ID and secret access key in the AWS Management Console.

Once you have entered this information, the AWS CLI is ready to use.

That’s it! You have successfully installed the AWS CLI on Linux Mint and configured it to access your AWS account. You can now use the CLI to manage your AWS resources from the command line.

Posted on Leave a comment

Installing and Setting Up Jenkins CI/CD on Linux Mint

Introduction:

Jenkins is an open-source automation server that helps automate parts of the software development process. With Jenkins, you can set up continuous integration and continuous deployment (CI/CD) for your projects, making it easier to build, test, and deploy applications. This guide will walk you through the process of installing and setting up Jenkins on Linux Mint

Prerequisites:

  • Linux Mint system
  • A user with sudo privileges
  • An internet connection

Step 1: Update Your System

Before installing Jenkins, it’s essential to update your system packages to their latest versions. To do this, open a terminal and run the following commands:

sudo apt update
sudo apt upgrade

Step 2: Install Java Development Kit (JDK)

Jenkins requires Java to run, so you will need to install the Java Development Kit (JDK). In this guide, we will use OpenJDK 11. Install OpenJDK 11 by running the following command:

sudo apt install openjdk-11-jdk

Verify the installation by checking the Java version:

java -version

Step 3: Add Jenkins Repository

Jenkins provides a dedicated repository for its packages. To add this repository to your system, first, install the necessary dependencies by running:

sudo apt install wget apt-transport-https gnupg

Next, import the GPG key for the Jenkins repository:

wget -q -O - https://pkg.jenkins.io/debian/jenkins.io.key | sudo gpg --dearmor -o /usr/share/keyrings/jenkins-archive-keyring.gpg

Now, add the Jenkins repository to your system:

echo "deb [signed-by=/usr/share/keyrings/jenkins-archive-keyring.gpg] https://pkg.jenkins.io/debian binary/" | sudo tee /etc/apt/sources.list.d/jenkins.list

Update the package list to include the Jenkins repository:

sudo apt update

Step 4: Install Jenkins

With the repository added, you can now install Jenkins by running:

sudo apt install jenkins

Step 5: Start and Enable Jenkins Service

Once Jenkins is installed, start the Jenkins service and enable it to run at system startup:

sudo systemctl start jenkins
sudo systemctl enable jenkins

Verify that Jenkins is running:

sudo systemctl status jenkins

Step 6: Configure Firewall ( optional for local install )

If you have a firewall enabled, you will need to allow traffic on port 8080, which is the default port Jenkins listens on. In this guide, we will use the UFW (Uncomplicated Firewall) to configure the firewall. If you don’t have UFW installed, you can install it by running:

sudo apt install ufw

Allow traffic on port 8080:

sudo ufw allow 8080

Step 7: Set Up Jenkins

Access the Jenkins web interface by opening a web browser and navigating to:

http://your_server_ip_or_domain:8080

You will be prompted for an unlock key. Retrieve the key by running:

sudo cat /var/lib/jenkins/secrets/initialAdminPassword

Copy the key and paste it into the web interface. Click “Continue” to proceed with the setup.

You will be presented with two options for plugin installation: “Install suggested plugins” and “Select plugins to install.” Choose the option that best suits your needs.

Create an admin user by providing a username, password, and email address. Click “Save and Continue” to proceed. Review the Jenkins URL and ensure that it is correct. Click “Save and Finish” to complete the setup.

Step 8: Accessing Jenkins Dashboard

You will now be redirected to the Jenkins dashboard. From here, you can create and manage jobs, install plugins, configure system settings, and monitor the status of your builds.

Conclusion:

You have successfully installed and set up Jenkins on Linux Mint 20. You can now start exploring Jenkins features and plugins to create your continuous integration and continuous deployment pipelines. With Jenkins, you can automate your software development processes, making it easier and more efficient to build, test, and deploy applications.