Coder Social home page Coder Social logo

aws_cli_utility's Introduction

AWS CLI Command Reference

This repository contains a collection of AWS CLI commands for managing various AWS services including EC2, EBS, S3, VPC, IAM, Lambda, RDS, and SNS. Each section is organized by service type for easy reference.

๐ŸŽฅ Video link: 70 AWS CLI Commands

EC2

Manage Amazon EC2 instances efficiently with these commands.

  1. Retrieve an EC2 Instance ID
aws ec2 describe-instances --query "Reservations[].Instances[].InstanceId" --output text
  1. Stop an EC2 Instance
aws ec2 start-instances --instance-ids <instance_id>
  1. Start an EC2 Instance
aws ec2 start-instances --instance-ids <instance_id>
  1. Terminate an EC2 Instance
aws ec2 terminate-instances --instance-ids <instance_id>
  1. Launch an EC2 Instance
aws ec2 run-instances --image-id <ami-id> --count 1 --instance-type <instance-type> --key-name <key-pair-name> --security-group-ids <security-group-name> --subnet-id <subnet-id>
  1. Modify an Instance Type
aws ec2 modify-instance-attribute --instance-id <instance_id> --instance-type "{"Value": "t2.large"}"
  1. Describe EC2 Instances with Tags
aws ec2 describe-instances --filters "Name=tag:Name,Values=dev-instance"
  1. List All EC2 Instances in Running State
aws ec2 describe-instances --filters "Name=instance-state-name,Values=running" --query "Reservations[].Instances[].[InstanceId,InstanceType,State.Name,PublicIpAddress]" --output table
  1. Get Console Output for an Instance
aws ec2 get-console-output --instance-id <instance_id>

EBS

Manage Amazon EBS volumes effectively with these commands

  1. Create an EBS Volume
aws ec2 create-volume --size 10 --volume-type gp3 --availability-zone us-east-1a
  1. Attach an EBS Volume to an Instance
aws ec2 attach-volume --volume-id <volume_id> --instance-id <instance_id> --device /dev/sdf
  1. Detach an EBS Volume
aws ec2 detach-volume --volume-id <volume_id>
  1. Delete an EBS Volume
aws ec2 delete-volume --volume-id <volume_id>
  1. Describe an EBS Volume
aws ec2 describe-volumes --volume-ids <volume_id>
  1. List EBS Volumes in Available State
aws ec2 describe-volumes --query "Volumes[?State!='in-use'].{ID:VolumeId, Size:Size, State:State}" --output table
  1. Modify an EBS Volume
aws ec2 modify-volume --volume-id <volume_id> --size 20
  1. Describe EBS Volume by Tags
aws ec2 describe-volumes --filters "Name=tag:Name,Values=MyVolume"

Snapshots

Handle AWS EBS snapshots efficiently with these commands.

  1. Create a Snapshot
aws ec2 create-snapshot --volume-id <volume_id> --description "My snapshot"
  1. List All Snapshots
aws ec2 describe-snapshots --owner-ids 123456789012
  1. Delete a Specific Snapshot
aws ec2 delete-snapshot --snapshot-id <snapshot_id>
  1. Copy a Snapshot from One Region to Another
aws ec2 copy-snapshot --source-region us-east-1 --source-snapshot-id <snapshot_id> --destination-region us-west-2 --description "Snapshot copy to us-west-2"
  1. Modify Snapshot Permission
aws ec2 modify-snapshot-attribute --snapshot-id <snapshot_id> --attribute createVolumePermission --operation-type add --user-ids 123456789012
  1. List Snapshot Based on Specific Tags
aws ec2 describe-snapshots --filters "Name=tag:Name,Values=MyProject"

S3 Commands

Manage Amazon S3 buckets and objects efficiently with these commands:

  1. Create an S3 Bucket
    aws s3 mb s3://mybucket
  2. List all S3 Buckets
    aws s3 ls
  3. Upload a File to an S3 Bucket
    aws s3 cp localfile.txt s3://mybucket/
  4. Delete a Bucket and All Its Contents
    aws s3 rb s3://mybucket --force
  5. List Objects in an S3 Bucket
    aws s3 ls s3://mybucket --recursive
  6. Copy an Object Between S3 Buckets
    aws s3 cp s3://mybucket1/myobject.txt s3://mybucket2/myobject.txt
  7. Delete an Object in an S3 Bucket
    aws s3 rm s3://mybucket/myobject.txt
  8. Enable Versioning in an S3 Bucket
    aws s3api put-bucket-versioning --bucket mybucket --versioning-configuration Status=Enabled

VPC Commands

Efficiently manage your AWS Virtual Private Cloud (VPC) environments with these commands:

  1. Create a VPC
    aws ec2 create-vpc --cidr-block 10.0.0.0/16
  2. Get the List of VPC IDs
    aws ec2 describe-vpcs --query 'Vpcs[*].VpcId' --output text
  3. Delete a Specific VPC
    aws ec2 describe-vpcs --query 'Vpcs[*].VpcId' --output text
  4. Create a Subnet
    aws ec2 create-subnet --vpc-id vpc-1234abcd --cidr-block 10.0.1.0/24
  5. Create an Internet Gateway and Attach to VPC
    aws ec2 create-internet-gateway
    aws ec2 attach-internet-gateway --vpc-id vpc-1234abcd --internet-gateway-id igw-1234abcd
  6. Create a Route Table and Associate It with Subnet
    aws ec2 create-route-table --vpc-id vpc-1234abcd
    aws ec2 associate-route-table --route-table-id rtb-1234abcd --subnet-id subnet-5678efgh
  7. Modify VPC Attribute and Enable DNS Hostname
    aws ec2 modify-vpc-attribute --vpc-id vpc-1234abcd --enable-dns-hostnames "{\"Value\":true}"
  8. Create a Security Group in a VPC
    aws ec2 create-security-group --group-name mySecurityGroup --description "My security group" --vpc-id vpc-1234abcd
  9. Add a Rule in Security Group
    aws ec2 authorize-security-group-ingress --group-id sg-1234abcd --protocol tcp --port 22 --cidr 0.0.0.0/0
  10. Create a NAT Gateway
    aws ec2 create-nat-gateway --subnet-id subnet-1234abcd --allocation-id eip-abcd1234
  11. Change the Security Group of an EC2 Instance
    aws ec2 modify-instance-attribute --instance-id <instance_id> --groups sg-98765432 sg-87654321

IAM Commands

Simplify identity and access management in AWS with these IAM operations:

  1. Create an IAM User
    aws iam create-user --user-name myUser
  2. List IAM Users
    aws iam list-users --query 'Users[*].UserName' --output text
  3. Attach a Policy to an IAM User
    aws iam attach-user-policy --policy-arn arn:aws:iam::aws:policy/AmazonS3FullAccess --user-name myUser
  4. Delete an IAM User
    aws iam delete-user --user-name myUser
  5. Create an Access Key and Secret Key for an IAM User
    aws iam create-access-key --user-name myUser
  6. Deactivate User Key
    aws iam update-access-key --access-key-id AKIAIOSFODNN7EXAMPLE --user-name myUser --status Inactive

Lambda Commands

Efficiently manage your AWS Lambda functions with these straightforward commands:

  1. Create a Lambda Function
    aws lambda create-function --function-name myFunction --runtime nodejs12.x --role arn:aws:iam::123456789012:role/lambda-role --handler index.handler --zip-file fileb://function.zip
  2. List Lambda Functions
    aws lambda list-functions
  3. Invoke a Lambda Function
    aws lambda invoke --function-name myFunction --payload '{"key": "value"}' response.json
  4. Delete a Lambda Function
    aws lambda delete-function --function-name myFunction
  5. Update Lambda Function
    aws lambda update-function-code --function-name myFunction --zip-file fileb://function.zip

RDS Commands

Efficiently manage your Amazon RDS instances with these commands:

  1. Create a Database Instance
    aws rds create-db-instance --db-instance-identifier mydbinstance --allocated-storage 20 --db-instance-class db.m1.small --engine mysql --master-username masteraws --master-user-password masterpassword
  2. List All RDS Instances
    aws rds describe-db-instances
  3. Delete a Database Instance (Skip Final Snapshot)
    aws rds delete-db-instance --db-instance-identifier mydbinstance --skip-final-snapshot
  4. Modify DB Instance
    aws rds modify-db-instance --db-instance-identifier mydbinstance --db-instance-class db.m4.large --apply-immediately
  5. Take a DB Snapshot
    aws rds create-db-snapshot --db-instance-identifier mydbinstance --db-snapshot-identifier mydbsnapshot
  6. Restore DB Snapshot
    aws rds restore-db-instance-from-db-snapshot --db-instance-identifier newdbinstance --db-snapshot-identifier mydbsnapshot
  7. Modify DB Instance Retention Policy
    aws rds modify-db-instance --db-instance-identifier mydbinstance --backup-retention-period 7 --apply-immediately
  8. Promote a Read Replica to Standalone Instance
    aws rds promote-read-replica --db-instance-identifier myreadreplica

SNS Commands

Manage Amazon Simple Notification Service (SNS) effectively with these commands:

  1. Create a New SNS Topic
    aws sns create-topic --name myTopic
  2. Subscribe an Email Address to SNS Topic
    aws sns subscribe --topic-arn arn:aws:sns:us-west-2:123456789012:myTopic --protocol email --notification-endpoint [email protected]
  3. Publish a Message to Specific Topic
    aws sns publish --topic-arn arn:aws:sns:us-west-2:123456789012:myTopic --message "Hello world"
  4. Delete a SNS Topic
    aws sns delete-topic --topic-arn arn:aws:sns:us-west-2:123456789012:myTopic

CloudWatch Commands

Effectively monitor and manage your AWS resources with these CloudWatch commands:

  1. Create a CloudWatch Alarm
    aws cloudwatch put-metric-alarm --alarm-name HighCPUUtilization --metric-name CPUUtilization --namespace AWS/EC2 --statistic Average --period 300 --threshold 80 --comparison-operator GreaterThanOrEqualToThreshold --dimensions Name=InstanceId,Value=i-1234567890abcdef0 --evaluation-periods 2 --alarm-actions arn:aws:sns:us-west-2:123456789012:myTopic
  2. Delete a CloudWatch Alarm
    aws cloudwatch delete-alarms --alarm-names HighCPUUtilization
  3. Get Data About Specific Metric in a Given Time Frame
    aws cloudwatch get-metric-statistics --namespace AWS/EC2 --metric-name CPUUtilization --start-time 2021-01-01T00:00:00Z --end-time 2021-01-02T00:00:00Z --period 3600 --statistics Average --dimensions Name=InstanceId,Value=i-0123456789abcdef0
  4. Describe Alarm History of a Specific Alarm
    aws cloudwatch describe-alarm-history --alarm-name HighCPUUtilization
  5. Manually Change the State of an Alarm for Testing Purposes
    aws cloudwatch set-alarm-state --alarm-name "MyAlarm" --state-reason "Manual trigger for testing" --state-value ALARM

aws_cli_utility's People

Contributors

100daysofdevops avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.