AWS Project using basic shell Scripting

In this project, we will print all the AWS resources using Shell Scripting

Log in to the AWS console and click on Security Credentials

Generate the Access keys and download the .csv file

Create an EC2 instance and start installing AWSCLI

sudo apt-get update
sudo apt install awscli -y
aws --version

Now configure the AWS by using the Access keys we generated earlier

aws configure

Let's check if we are connected to the AWS console by using the below commands

aws s3 ls
aws ec2 describe-instances

Write a shell script to print all the AWS resources

echo "This Script will report AWS resources"
set -x

########################
echo "List of S3 buckets"
aws s3 ls

echo "List of Ec2 instances"
aws  ec2  describe-instances

echo "list of lambda functions"
aws lambda list-functions

echo "list the IAM USERS"
aws iam list-users

To print only the instance id and IAM user names

sudo apt install jq -y
aws ec2 describe-instances | jq '.Reservations[].Instances[].InstanceId'
aws iam list-users | jq '.Users[].UserName'

Replace these commands in the main shell script

echo "This Script will report AWS resources"
set -x

echo "List of S3 buckets"
aws s3 ls > text.txt

echo "List of Ec2 instances"
aws ec2 describe-instances | jq '.Reservations[].Instances[].InstanceId'

echo "list of lambda functions"
aws lambda list-functions >> text.txt

echo "list the IAM USERS"
aws iam list-users | jq '.Users[].UserName' >> text.txt