├── LICENSE ├── README.md └── aws ├── EC2.md ├── EC2CheatSheet.png ├── IAM.md ├── IAMCheatSheet.png └── S3CheatSheet.jpg /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Rishab Kumar 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Cloud CLI Cheatsheets 2 | 3 | ![GitHub Repo stars](https://img.shields.io/github/stars/rishabkumar7/aws-cheat-sheets?style=social) 4 | [![Hits](https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https%3A%2F%2Fgithub.com%2Frishabkumar7%2Faws-cheat-sheets&count_bg=%2379C83D&title_bg=%23555555&icon=&icon_color=%23E7E7E7&title=hits&edge_flat=false)](https://hits.seeyoufarm.com) 5 | 6 | I have generated some handmade Cloud CLI cheat sheets, which can be printed. 7 | 8 | There are both [handmade](#handmade) and [markdown](#markdown) versions available: 9 | 10 | ## Markdown 11 | 12 | - AWS 13 | - [IAM](aws/IAM.md) 14 | - [EC2](aws/EC2.md) 15 | - [S3](aws/S3.md) 16 | 17 | ## Handmade 18 | 19 | ### AWS 20 | 21 | #### EC2 22 | 23 | ![EC2](aws/EC2CheatSheet.png) 24 | 25 | #### S3 26 | 27 | ![S3](aws/S3CheatSheet.jpg) 28 | 29 | #### IAM 30 | 31 | ![IAM](aws/IAMCheatSheet.png) 32 | -------------------------------------------------------------------------------- /aws/EC2.md: -------------------------------------------------------------------------------- 1 | ## EC2 2 | 3 | ### keypairs 4 | 5 | http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-key-pairs.html 6 | 7 | ```shell 8 | # list all keypairs 9 | aws ec2 describe-key-pairs 10 | 11 | # create a keypair 12 | aws ec2 create-key-pair \ 13 | --key-name --output text 14 | 15 | # create a new local private / public keypair, using RSA 4096-bit 16 | ssh-keygen -t rsa -b 4096 17 | 18 | # import an existing keypair 19 | aws ec2 import-key-pair \ 20 | --key-name keyname_test \ 21 | --public-key-material file:///home/apollo/id_rsa.pub 22 | 23 | # delete a keypair 24 | aws ec2 delete-key-pair \ 25 | --key-name 26 | ``` 27 | 28 | 29 | ### Security Groups 30 | 31 | http://docs.aws.amazon.com/cli/latest/reference/ec2/index.html 32 | 33 | ```shell 34 | # list all security groups 35 | aws ec2 describe-security-groups 36 | 37 | # create a security group 38 | aws ec2 create-security-group \ 39 | --vpc-id vpc-1a2b3c4d \ 40 | --group-name web-access \ 41 | --description "web access" 42 | 43 | # list details about a securty group 44 | aws ec2 describe-security-groups \ 45 | --group-id sg-0000000 46 | 47 | # open port 80, for everyone 48 | aws ec2 authorize-security-group-ingress \ 49 | --group-id sg-0000000 \ 50 | --protocol tcp \ 51 | --port 80 \ 52 | --cidr 0.0.0.0/24 53 | 54 | # get my public ip 55 | my_ip=$(dig +short myip.opendns.com @resolver1.opendns.com); 56 | echo $my_ip 57 | 58 | # open port 22, just for my ip 59 | aws ec2 authorize-security-group-ingress \ 60 | --group-id sg-0000000 \ 61 | --protocol tcp \ 62 | --port 80 \ 63 | --cidr $my_ip/24 64 | 65 | # remove a firewall rule from a group 66 | aws ec2 revoke-security-group-ingress \ 67 | --group-id sg-0000000 \ 68 | --protocol tcp \ 69 | --port 80 \ 70 | --cidr 0.0.0.0/24 71 | 72 | # delete a security group 73 | aws ec2 delete-security-group \ 74 | --group-id sg-00000000 75 | ``` 76 | 77 | 78 | 79 | 80 | ## Images 81 | 82 | https://docs.aws.amazon.com/cli/latest/reference/ec2/describe-images.html 83 | 84 | ```shell 85 | # list all private AMI's, ImageId and Name tags 86 | aws ec2 describe-images --filter "Name=is-public,Values=false" \ 87 | --query 'Images[].[ImageId, Name]' \ 88 | --output text | sort -k2 89 | 90 | # delete an AMI, by ImageId 91 | aws ec2 deregister-image --image-id ami-00000000 92 | 93 | ``` 94 | 95 | 96 | ## Instances 97 | 98 | http://docs.aws.amazon.com/cli/latest/reference/ec2/index.html 99 | 100 | ```shell 101 | # list all instances (running, and not running) 102 | aws ec2 describe-instances 103 | 104 | # list all instances running 105 | aws ec2 describe-instances --filters Name=instance-state-name,Values=running 106 | 107 | # create a new instance 108 | aws ec2 run-instances \ 109 | --image-id ami-a0b1234 \ 110 | --instance-type t2.micro \ 111 | --security-group-ids sg-00000000 \ 112 | --dry-run 113 | 114 | # stop an instance 115 | aws ec2 terminate-instances \ 116 | --instance-ids 117 | 118 | # list status of all instances 119 | aws ec2 describe-instance-status 120 | 121 | # list status of a specific instance 122 | aws ec2 describe-instance-status \ 123 | --instance-ids 124 | 125 | # list all running instance, Name tag and Public IP Address 126 | aws ec2 describe-instances \ 127 | --filters Name=instance-state-name,Values=running \ 128 | --query 'Reservations[].Instances[].[PublicIpAddress, Tags[?Key==`Name`].Value | [0] ]' \ 129 | --output text | sort -k2 130 | ``` 131 | 132 | 133 | 134 | ### Tags 135 | ```shell 136 | # list the tags of an instance 137 | aws ec2 describe-tags 138 | 139 | # add a tag to an instance 140 | aws ec2 create-tags \ 141 | --resources "ami-1a2b3c4d" \ 142 | --tags Key=name,Value=debian 143 | 144 | # delete a tag on an instance 145 | aws ec2 delete-tags \ 146 | --resources "ami-1a2b3c4d" \ 147 | --tags Key=Name,Value= 148 | ``` -------------------------------------------------------------------------------- /aws/EC2CheatSheet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rishabkumar7/cloud-cheat-sheets/a2df3e9f861a5cf7d39579137c6f503e62767ef1/aws/EC2CheatSheet.png -------------------------------------------------------------------------------- /aws/IAM.md: -------------------------------------------------------------------------------- 1 | ## IAM 2 | http://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html 3 | ### Users 4 | 5 | ```shell 6 | # list all user's info 7 | aws iam list-users 8 | 9 | # list all user's usernames 10 | aws iam list-users --output text | cut -f 6 11 | 12 | # list current user's info 13 | aws iam get-user 14 | 15 | # list current user's access keys 16 | aws iam list-access-keys 17 | 18 | # crate new user 19 | aws iam create-user \ 20 | --user-name UserName 21 | 22 | # create multiple new users, from a file 23 | allUsers=$(cat ./user-names.txt) 24 | for userName in $allUsers; do 25 | aws iam create-user \ 26 | --user-name $userName 27 | done 28 | 29 | # list all users 30 | aws iam list-users --no-paginate 31 | 32 | # get a specific user's info 33 | aws iam get-user \ 34 | --user-name UserName 35 | 36 | # delete one user 37 | aws iam delete-user \ 38 | --user-name UserName 39 | 40 | # delete all users 41 | # allUsers=$(aws iam list-users --output text | cut -f 6); 42 | allUsers=$(cat ./user-names.txt) 43 | for userName in $allUsers; do 44 | aws iam delete-user \ 45 | --user-name $userName 46 | done 47 | ``` 48 | 49 | 50 | ### Access Keys 51 | 52 | http://docs.aws.amazon.com/cli/latest/reference/iam/ 53 | 54 | ```shell 55 | # list all access keys 56 | aws iam list-access-keys 57 | 58 | # list access keys of a specific user 59 | aws iam list-access-keys \ 60 | --user-name UserName 61 | 62 | # create a new access key 63 | aws iam create-access-key \ 64 | --user-name UserName \ 65 | --output text | tee UserName.txt 66 | 67 | # list last access time of an access key 68 | aws iam get-access-key-last-used \ 69 | --access-key-id AKIZNAA7RKZY4EXAMPLE 70 | 71 | # deactivate an acccss key 72 | aws iam update-access-key \ 73 | --access-key-id AKIZNAA7RKZY4EXAMPLE \ 74 | --status Inactive \ 75 | --user-name UserName 76 | 77 | # delete an access key 78 | aws iam delete-access-key \ 79 | --access-key-id AKIZNAA7RKZY4EXAMPLE \ 80 | --user-name UserName 81 | ``` 82 | 83 | 84 | ### Groups, Policies, Managed Policies 85 | 86 | http://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles.html 87 | http://docs.aws.amazon.com/cli/latest/reference/iam/ 88 | 89 | ```shell 90 | # list all groups 91 | aws iam list-groups 92 | 93 | # create a group 94 | aws iam create-group --group-name GroupName 95 | 96 | # delete a group 97 | aws iam delete-group \ 98 | --group-name GroupName 99 | 100 | # list all policies 101 | aws iam list-policies 102 | 103 | # get a specific policy 104 | aws iam get-policy \ 105 | --policy-arn 106 | 107 | # list all users, groups, and roles, for a given policy 108 | aws iam list-entities-for-policy \ 109 | --policy-arn 110 | 111 | # list policies, for a given group 112 | aws iam list-attached-group-policies \ 113 | --group-name GroupName 114 | 115 | # add a policy to a group 116 | aws iam attach-group-policy \ 117 | --group-name GroupName \ 118 | --policy-arn arn:aws:iam::aws:policy/AdministratorAccess 119 | 120 | # add a user to a group 121 | aws iam add-user-to-group \ 122 | --group-name GroupName \ 123 | --user-name UserName 124 | 125 | # list users, for a given group 126 | aws iam get-group \ 127 | --group-name GroupName 128 | 129 | # list groups, for a given user 130 | aws iam list-groups-for-user \ 131 | --user-name UserName 132 | 133 | # remove a user from a group 134 | aws iam remove-user-from-group \ 135 | --group-name GroupName \ 136 | --user-name UserName 137 | 138 | # remove a policy from a group 139 | aws iam detach-group-policy \ 140 | --group-name GroupName \ 141 | --policy-arn arn:aws:iam::aws:policy/AdministratorAccess 142 | 143 | # delete a group 144 | aws iam delete-group \ 145 | --group-name GroupName 146 | ``` 147 |


-------------------------------------------------------------------------------- /aws/IAMCheatSheet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rishabkumar7/cloud-cheat-sheets/a2df3e9f861a5cf7d39579137c6f503e62767ef1/aws/IAMCheatSheet.png -------------------------------------------------------------------------------- /aws/S3CheatSheet.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rishabkumar7/cloud-cheat-sheets/a2df3e9f861a5cf7d39579137c6f503e62767ef1/aws/S3CheatSheet.jpg --------------------------------------------------------------------------------