You are on page 1of 8

What is the AWS Command Line

Interface?

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 enables you to start running
commands that implement functionality equivalent to that provided by the
browser-based AWS Management Console from the command prompt in your
terminal program.

 Linux shells – Use common shell programs such as bash, zsh and tcsh to run commands in
Linux or macOS.

 Windows command line – On Windows, run commands at the Windows command prompt
or in PowerShell.

 Remotely – Run commands on Amazon Elastic Compute Cloud (Amazon EC2) instances
through a remote terminal program such as PuTTY or SSH, or with AWS Systems Manager.

The AWS CLI provides direct access to the public APIs of AWS services. You can
explore a service's capabilities with the AWS CLI, and develop shell scripts to manage
your resources. In addition to the low-level, API-equivalent commands, several AWS
services provide customizations for the AWS CLI. Customizations can include higher-
level commands that simplify using a service with a complex API.
Purpose of aws CLI

The AWS Command Line Interface (CLI) is a tool provided by Amazon Web Services (AWS) that
allows users to interact with various AWS services and resources through a command-line
interface. It serves several purposes

1) Automation and Scripting: The AWS CLI allows users to automate various tasks,
manage resources, and perform operations through scripts or batch processes. This
enables efficient management and provisioning of AWS resources without the need
for manual intervention.
2) Management of AWS Resources: The CLI provides a streamlined way to manage AWS
resources such as EC2 instances, S3 buckets, Lambda functions, databases, and more.
Users can create, configure, update, and delete resources using CLI commands.
3) Development and Testing: Developers often use the AWS CLI to interact with AWS
services while developing and testing applications. This can include deploying code,
testing APIs, and configuring services in a controlled manner.
4) Infrastructure as Code (IaC): The CLI is often used in conjunction with Infrastructure
as Code tools like AWS CloudFormation or Terraform. It helps in deploying and
managing infrastructure configurations through code, ensuring consistency and
repeatability.
5) Data Management: The CLI allows users to manage data stored in AWS services such
as Amazon S3, Amazon RDS, Amazon DynamoDB, etc. Users can upload, download,
list, and manipulate data through CLI commands.
6) Security and Access Control: The CLI enables users to configure security settings,
access controls, and authentication mechanisms for AWS resources. This includes
setting up permissions, roles, and policies.
7) Monitoring and Logging: Users can retrieve information about their AWS resources,
monitor their usage, and access logs using CLI commands. This can be useful for
analyzing usage patterns, debugging, and maintaining operational visibility.
8) Cross-Platform Support: The AWS CLI is available for various operating systems,
making it accessible to a wide range of users regardless of their preferred development
environment.
9) Integration with Other Tools: The AWS CLI can be integrated into other tools, scripts,
and processes, making it a versatile tool for building custom workflows and
integrations.
10) Learning and Training: Learning and practicing AWS CLI commands can be beneficial
for gaining a deeper understanding of how AWS services work and interact. It's often
used by individuals studying for AWS certifications.

In summary, the AWS CLI is a versatile tool that provides users with a powerful way to interact
with and manage AWS services from the command line. It's an essential component of the
AWS ecosystem for developers, administrators, and anyone working with AWS resources.
To access an AWS account using the AWS Command Line
Interface (CLI), you need to meet several key requirements to
ensure secure and proper access. Here are the essential
requirements:

 AWS Account: You need to have an active AWS account. If you


don't have one, you can sign up for an AWS account on the AWS
website.
 Install AWS CLI: Install the AWS CLI on your local machine. You can
download and install the CLI appropriate for your operating system from the
AWS CLI official installation page.

Access Credentials:
 Access Key ID: This is a long alphanumeric string that serves as your AWS
user identifier.
 Secret Access Key: This is a secret key associated with your Access Key ID. It's
used to sign your requests to AWS services.
You can obtain these credentials by creating an IAM (Identity and Access
Management) user with appropriate permissions in the AWS Management Console.
It's recommended to create users with the least privilege principle, granting them
only the permissions they need.

IAM User and Permissions: Create an IAM user in the AWS Management Console with
appropriate permissions to access the AWS resources you intend to manage using the CLI.
You should attach a policy to the IAM user that grants the necessary permissions. Be
cautious not to grant overly permissive permissions.
Configure AWS CLI: After installing the AWS CLI, you need to configure it with your
credentials. Run the following command and provide your Access Key ID and Secret Access
Key when prompted:

aws configure
You'll also need to specify the default AWS region you want to work with.
The aws configure command is used in the AWS Command Line Interface (CLI) to set up
your access credentials and default configurations. When you run this command, you will be
prompted to enter your AWS Access Key ID, AWS Secret Access Key, default AWS region,
and default output format. Here's how you can use the aws configure command:

You will be prompted to enter the following information:


 AWS Access Key ID: Enter your AWS Access Key ID associated with your IAM
user.
 AWS Secret Access Key: Enter your Secret Access Key associated with the
above Access Key ID.
 Default region name: Enter the AWS region code (ap-south-1) you want to
use as the default for your commands.
 Default output format: Choose the desired output format for AWS CLI
responses. You can choose from options like json, text, or table.
Before running cli command

aws s3 mb s3://amayratask
 aws: This is the AWS CLI command used to interact with various AWS services.
 s3: This specifies that you're working with Amazon S3, the Simple Storage Service.
 mb: Stands for "make bucket." This command is used to create an S3 bucket.
 s3://amayratask: This is the URL of the bucket you want to create. The format is
s3://bucket-name, where bucket-name is the name you want to give to the bucket.

It will create an S3 bucket named amayratask. Please note that S3 bucket names are
globally unique across all AWS accounts, so you might need to choose a different name if
the one you provided is already in use.
Bucket created successfully

aws s3 cp .\Desktop\Desktop\Amayra\sajid.jpg s3://amayratask

The command you've provided is used to copy a local file to an S3 bucket using the AWS
Command Line Interface (CLI). Here's the breakdown of the command:

 aws: The AWS CLI command.


 s3: Indicates you're working with Amazon S3.
 cp: Stands for "copy." This command is used to copy files between your local
machine and S3.
 .\Desktop\Desktop\Amayra\sajid.jpg: This is the local file path of the file you
want to copy. Make sure the path is correct.
 s3://amayratask: This is the URL of the S3 bucket where you want to copy the file.

It will copy the sajid.jpg file from the specified local path to the root of the amayratask
S3 bucket. If you want to specify a different destination within the bucket or change the
object name, you can modify the S3 URL accordingly.

Please note that you need to have appropriate permissions to perform the s3 cp operation,
and your AWS CLI should be properly configured with access credentials.
aws s3 presign s3://amayratask/sajid.jpg --expires-in 60

The command aws s3 presign generates a pre-signed URL for accessing an S3 object. A
pre-signed URL is a URL that provides temporary access to the object without requiring AWS
credentials. The --expires-in flag specifies the duration for which the pre-signed URL will
be valid (in seconds).

This command generates a pre-signed URL that allows someone to access the sajid.jpg
object in the amayratask S3 bucket. The pre-signed URL will be valid for 60 seconds (1
minute).

If you were to run this command, it would output the pre-signed URL to the terminal. You
can then use this URL to access the object without needing to provide AWS credentials, as
long as it's within the specified expiration time. Keep in mind that anyone who possesses this
URL will have temporary access to the object during the validity period.

Image displays only for 60 seconds


After 60 sec (1 min) link get expired, and image is not visible.

You might also like