Skip to main content

Command Palette

Search for a command to run...

Day 42- 90DaysOfDevOps

IAM Programmatic access and AWS CLI

Published
3 min read
Day 42- 90DaysOfDevOps

Hey Learners! Welcome back. We understood the concept of Load Balancer in the previous challenge. In this challenge, we look at the concept of AWS CLI and how to have programmatic access. Let's start...

IAM Programmatic Access:-

To access your AWS account from a terminal or system, you can use AWS Access Keys and AWS Secret Access Keys.

AWS CLI:-

The AWS Command Line Interface(CLI) is a unified tool to manage your AWS services. With just one tool to download and configure, you can control multiple AWS services from the command line and automate them through scripts.

The AWS CLI v2 offers several new features including improved installers, new configuration options such as AWS IAM identity centre (successor to AWS SSO), and various interactive features.

Task 1- Create AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY from AWS Console

Sign in to the AWS console with your credentials select username on the top right of the AWS console and select Security credentials from the dropdown menu.

Scroll down to Access keys section and click Create access keys.

If you are not an IAM user you need to check the below warning and proceed to Create access key.

Your access key gets created. You can download a .csv file or you can copy the Access and Secret access keys directly. Done.

This is how we can create Access and Secret access keys for a root account.

If you want to have keys for IAM users then select Users from the Left navigation pane and click on the Security credentials tab as shown below and you will find the Access keys section after scrolling down.

Task 2- Setup and install AWS CLI and configure your account credentials

First, we have to search for "AWS CLI install v2" choose OS as required and download the setup for the selected OS.

Link to download:- https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html

I am going to install AWS CLI on Ubuntu.

  • Command to download and save the file as awscliv2.zip on the current directory.

      curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
    
  • Use the command to unzip the downloaded file

      unzip awscliv2.zip
    
  • To run the install program.

      sudo ./aws/install
    
  • Installation done. To see a version of AWS CLI use

      aws --version
    

Now we have to configure AWS CLI using the aws configure command. Enter the Access and Secret Access Keys created earlier for configuring AWS CLI.

Let's try to interact with AWS services with AWS CLI.

Example:- Use aws ec2 describe-instances Command to list all instances with detailed information.

You can do anything If you know the commands, a CLI can be a lot faster and more efficient than any other type of interface.

Thank you so much for taking the time to read till the end! Hope you found this blog informative.

Feel free to explore more of my content, and don't hesitate to reach out if need any assistance from me or in case of you have any questions.

Find me on:- Hashnode LinkedIn Github

Happy Learning!