AWS provides many ways to interact with its APIs to create, update, and remove its services. One way is to use AWS CLI.
What is AWS CLI?
AWS CLI is a command line tool that allows you to create, update, and remove all the services in AWS. You can do everything you can with the AWS Web Console using the AWS CLI.
Using AWS CLI is much faster and better for large resource deployment. And for using IaC, like Terraform you must use AWS CLI.
Step – 1
Before you install any packages make sure you have updated your package manager using `sudo apt update` for Debian-based distro. For red hat OS, you can use `sudo yum update`, and for arch-based OS use `sudo pacman -Sy`. For this demonstration, we will use Ubuntu, a debian distro.
Step – 2
After you have updated, make sure you have curl installed. You can install curl using `sudo apt install curl`.
Step – 3
Now you need to install unzip. You can do this using the `sudo apt install unzip` command.
Step – 4
Now navigate to this URL https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html and scroll down and from the “Linux x86 (64 bit)” tab copy the first command and paste it.
“`
unzip awscliv2.zip
sudo ./aws/install
“`
This will install the AWS CLI from AWS’s official repository and install it in your operating system.
Step – 5
Once it’s installed you can use the command `aws –version` to verify the installation.
That’s it AWS CLI is now installed in your operating system. You can now generate an access key and use the command `aws configure` to configure your AWS-CLI.
AWS CLI Basic Commands
Here are some basic commands for AWS-CLI.
S3
aws s3 ls: Lists all your buckets or the contents of a specified bucket.
aws s3 cp: Copies files and directories between your local system and S3.
aws s3 mv: Moves files and directories between your local system and S3.
aws s3 rm: Removes files or directories.
EC2
aws ec2 describe-instances: Provides information about your EC2 instances.
aws ec2 start-instances –instance-ids i-1234567890abcde0: Starts a specified instance.
aws ec2 stop-instances –instance-ids i-1234567890abcde0: Stops a specified instance.
aws ec2 terminate-instances –instance-ids i-1234567890abcdef0: Terminates a specified instance.
IAM
aws iam list-users: Lists all users.
aws iam create-user –user-name new_user: Creates a new user.
aws iam delete-user –user-name old_user: Deletes a user.
For more article on AWS follow here.
Komentarze