Open In App

How To Use AWS EC2, EBS, and S3 Services Using AWS CLI?

Improve
Improve
Like Article
Like
Save
Share
Report

Pre-requisite: EC2, EBS and S3

The AWS Command Line Interface (AWS CLI) is an open-source tool that enables you to interact with AWS services using commands in your command-line shell. With minimal configuration, the AWS CLI provides you with the ability to quickly and easily access the same functionality as the browser-based AWS Management Console from the comfort of your terminal program.

Steps to Implement

Step 1: Download the AWS Command Line Interface (CLI) software from AWS Console. With the AWS CLI, you can easily manage your AWS services from the command line, making it a powerful and convenient tool for managing your cloud infrastructure. Click on the Windows icon and download the software. 

After installation, open the command prompt and type the command:

aws --version

It is to verify the installation. This will ensure that the software is properly installed and ready to use.

aws version

 

Step 2: Now, we need to configure AWS in order to take advantage of its powerful cloud computing capabilities. With AWS, you can access a wide range of services, from storage and databases to analytics and machine learning, to help you build and scale your applications. Configuring AWS is easy and straightforward, allowing you to quickly get up and running with the cloud.

Console

 

Steps To Create an IAM user in AWS: 

  • Step i: Log in to the AWS console and search for the IAM service.
IAM Dashboard

 

  • Step ii: Navigate to the Users tab and Click on the ‘Add user’ button.
add user

 

  • Step iii: Enter a Username.
  • Step iv: Select an Access Key and click ‘Next’.
Access Key

 

  • Step v: Select the ‘Administrator Access’ option and click ‘Next’.
Administrator Access

 

  • Step vi: Click on the ‘Create user’ button.

create user

 

successfully created.

 

Step 3: Log in to AWS CLI using your Access Key ID and Secret Access Key for secure access to your account. With these credentials, you can access your account and take advantage of the powerful features of the AWS Command Line Interface.

Download the .csv File by following these Steps

  • Open the command line and type in the command 
aws configure
  • Copy and paste your IAM user Access Key ID and Secret Access Key into the command line.
  • Enter the region name where you would like to launch your instance.
  • Select the output format, such as JSON.
cmd to download csv file

 

Step 4: Launch an Amazon EC2 Instance with AWS CLI.

Utilizing the AWS Command Line Interface (CLI), you can quickly and easily launch an Amazon EC2 instance, allowing you to access the power of the cloud with just a few simple commands. With the AWS CLI, you can quickly and easily spin up a virtual machine in the cloud, giving you the ability to access the power of the cloud with ease.

We will launch an EC2 instance with the help of this command. You can select any image ID from the AWS console, use an existing key-pair, select any existing security group ID, and use any existing subnet ID. All of these IDs must belong to the same availability zone for the instance to be launched successfully.

 Launch an Amazon EC2 Instance with AWS CLI.

 

Now, we have successfully launched an EC2 instance, unlocking a world of possibilities for our business. With this new instance, we can take advantage of the scalability, flexibility, and cost-effectiveness of the cloud, allowing us to quickly and easily deploy applications and services. This will enable us to stay ahead of the competition and remain competitive in the ever-evolving digital landscape.

Step 5: Create a Key Pair using the AWS Command Line Interface (CLI). Utilizing the CLI allows for a more efficient and secure way to generate a key pair, ensuring that your data remains safe and secure. With the CLI, you can quickly and easily generate a key pair that will provide you with the highest level of security for your data.

Create a key pair using this command. This command will enable you to securely generate a unique set of cryptographic keys that can be used to authenticate and encrypt data. With this key pair, you can ensure that your data is kept safe and secure.

aws ec2 create-key-pair 
--key-name vivek1

Provide the name of the key pair to gain access.

 

Now successfully created, this accomplishment marks a milestone in our journey toward success. We have worked hard to reach this point, and we are proud of the progress we have made. This achievement is a testament to our dedication and commitment to excellence.

Step 6: Utilizing the AWS Command Line Interface (CLI), we will create an Elastic Block Store (EBS) Volume to store our data. This will provide us with a secure, reliable, and cost-effective storage solution for our data.

Using this command, you can create an EBS Volume. This powerful tool allows you to quickly and easily create a reliable storage solution for your data. With EBS Volume, you can store your data securely and access it whenever you need it. Plus, you can scale up or down as needed, giving you the flexibility to meet your changing storage needs.

 

Now Successfully Created.

Step 7: We will attach EBS volume to EC2 Instance using AWS CLI.

Using this command attach EBS Volume to EC2 Instance.

aws ec2 attach-volume 
--volume-id vol-1234567890abcdef0 
--instance-id i-01474ef662b89480 
--device /dev/sdf
attach EBS volume to EC2 Instance using AWS CLI

 

Step 8: We will create a Security Group using AWS CLI. Use the following command:

aws ec2 create-security-group 
--group-name my-sg --description 
"My sg group" --vpc-id vpc-f0e73c9b
  • VPC ID: To find the VPC ID, navigate to the VPC service in the Amazon EC2 console and click on VPCs.

Now, we have successfully created a security group in Amazon EC2, allowing us to secure our resources and protect our data.

create Security Group

 

Step 9: Utilizing the AWS Command Line Interface (CLI), we will create an S3 Bucket to store our data. This bucket will provide a secure and reliable storage solution for our data, ensuring that it is always accessible and protected.

  • To upload an object to an S3 bucket, use the command:
aws s3 cp object_name s3://bucketname
upload an object to an S3 bucket

 

  • Then, use this command: 
aws s3api put-object-acl 
— bucket (bucketname) — key 
(object-name) — acl-public-read

Now, the object is accessible to the public.

Step 10: After you the successfully done all the steps you can see your object in your web browser using the object URL.

output

 



Last Updated : 28 Mar, 2023
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads