Day 42: IAM Programmatic access and AWS CLI.

Day 42: IAM Programmatic access and AWS CLI.

Today I have covered,

  • What are IAM Programmatic Access and AWS CLI?

  • How to connect IAM Programmatic Access and AWS CLI?

What is IAM Programmatic access?

  • Programmatic access allows you to invoke actions on your AWS resources either through an application that you write or through a third-party tool. You use an access key ID and a secret access key to sign your requests for authorization to AWS.

  • Programmatic access can be pretty powerful, so implementing best practices to protect access key IDs and secret access keys is essential to prevent accidental or malicious account activity.

What is AWS CLI?

  • The AWS Command Line Interface (AWS 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 Center (successor to AWS SSO), and various interactive features.


Task-01

Create AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY from AWS Console.

  • Step-01: Go to AWS Console -> Security credentials -> Access keys (access key ID and secret access key)

  • Step-02: Click on Create New Access Key which will generate AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY for you.

imageedit_7_3108766430

  • Step-03: Download the CSV file which contains the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY for you.

imageedit_13_7631529106

  • Step 04: Verify the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY in the CSV file.

Screenshot from 2023-07-05 22-58-50

Thus we have created an Access key ID and a Secret access key now we will connect to AWS CLI.


Task-02

Setup and install AWS CLI and configure your account credentials.

  • Step-01: Install AWS CLI using the following command
sudo apt update
sudo apt install unzip
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install

imageedit_17_3657219052

  • Step-02: Verify the installation using the following command
aws --version

imageedit_19_8441271999

  • Step-03: Configure the AWS CLI using the following command in which we will provide the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY which we created in the previous task and also provide the the region we want to work and the output format.
aws configure

imageedit_25_2247222209

  • Step-04: Verify the configuration using the following command which will show the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY which we have provided in the previous step.
aws configure list

Screenshot from 2023-07-06 00-05-06

  • Step-05: We can check whether the AWS CLI is working or not by checking the Ec2 instance using the following command.
aws ec2 describe-instances

imageedit_27_2728458765


Happy Learning :)

Did you find this article valuable?

Support DevOps by becoming a sponsor. Any amount is appreciated!