1. To Install and Configure AWS CLI, use the below commands –
Syntax/ example:
sudo apt-get install -y python-dev python-pip
sudo pip install awscli
The syntax for configure:
aws configure
2. To check the output of the file, the command is –
Syntax/ example:
cat
3. To print the second column per line, use the below command –
Syntax/ example:
cut –f 2
4. For data sorting, the command used is –
Syntax/ example:
Sort
5. To print the last five-line, the command is –
Syntax/ example:
tail –n 5
6. To print the first five lines, the command is –
Syntax/ example:
head –n 5
7. To print the 5th line in a file, the command is –
Syntax/ example:
sed –n ‘5{p;q}’
8. To list all the trails, the command is –
Syntax/ example:
aws cloudtrail describe-trails
9. To list the names of all trails, the command is –
Syntax/ example:
aws cloud trail describe-trails –output text | cut –f 8
To delete the trail, the command is –
Syntax/ example:
aws cloud trail delete—trail
Intermediate AWS Commands
Given below are the intermediate AWS commands:
1. To add the tags to the trail, the command is –
Syntax/ example:
awscliaws cloudtrail add-tags \
--resource-id awslog \
--tags-list "Key=log-type,Value=all"
2. To list all the tags of the trail, the command is –
Syntax/ example:
aws cloudtrail list-tags\ --resource-id-list
3. To remove the tag from a trail –
Syntax/ example:
aws cloudtrail remove-tags \
--resource-id awslog \
--tags-list "Key=log-type,Value=all"
4. To list all the user’s info and creating the new user, the commands are –
Syntax/ example:
aws iam list-users
New user: aws iam create-user \
--user-name aws-admin1
5. To create multiple users from the file, the command is –
Syntax/ example:
allUsers=$(cat ./user-names.txt)
for userName in $allUsers; do
aws iam create-user \
--user-name $userName
Done
6. To delete multiple users from the file, the command is –
Syntax/ example:
allUsers=$(cat ./user-names.txt)
for userName in $allUsers; do
aws iam delete-user \
--user-name $userName
Done
7. To get the specific user information, the command is –
Syntax/ example:
aws iam get-user \
--user-name aws-admin1
8. To list the password policy, the command is –
Syntax/ example:
aws iam get-account-password-policy
9. To set the policy for a password, the command is –
Syntax/ example:
aws iam update-account-password-policy \
--minimum-password-length 12 \
--require-symbols \
--require-numbers \
--require-uppercase-characters \
--require-lowercase-characters \
--allow-users-to-change-password
10. To delete the password policy, the command is –
Syntax/ example:
aws iam delete-account-password-policy
Advanced AWS Commands
Given below are the commands mentioned:
1. To get the list of the last access time of the access key, the command is –
Syntax/ example:
aws iam get-access-key-last-used \
--access-key-id ABCDEFGH123456EXAMPLE
2. To deactivate the access key, the command is –
Syntax/ example:
aws iam update-access-key \
--access-key-id ABCDEFGH123456EXAMPLE\
--status Inactive \
--user-name aws-admin1
3. To delete the access key, the command is –
Syntax/ example:
aws iam delete-access-key \
--access-key-id ABCDEFGH123456EXAMPLE\
--user-name aws-admin1
4. To create a security group, the command is –
Syntax/ example:
aws ec2 create-security-group \
--vpc-id vpc-1a2b3c4d \
--group-name web-access \
--description "web access"
5. To open the port 80 for everyone to access, the command is –
Syntax/example:
aws ec2 authorize-security-group-ingress \
--group-id sg-0000000 \
--protocol tcp \
--port 80 \
--cidr 0.0.0.0/24
6. To remove the firewall from the group, the command is –
Syntax/ example:
aws ec2 revoke-security-group-ingress \
--group-id sg-0000000 \
--protocol tcp \
--port 80 \
--cidr 0.0.0.0/24
7. To delete the security group, the command is –
Syntax/ example:
aws ec2 delete-security-group \
--group-id sg-00000000
8. To create the instance, the command is –
Syntax/ example:
aws ec2 run-instances \
--image-id ami-f0e7d19a \
--instance-type t2.micro \
--security-group-ids sg-00000000 \
--dry-run
9. To create the log stream, the command is –
Syntax/ example:
aws logs create-log-stream \
--log-group-name "DefaultGroup" \
--log-stream-name "syslog"
10. To delete the log stream, the command is –
Syntax/ example:
aws logs delete-log-stream \
--log-group-name "DefaultGroup" \
--log-stream-name "Default Stream"