Below is a condensed AWS (Amazon Web Services) cheat sheet covering common services, CLI commands, and best practices:
AWS CLI Installation
Install AWS CLI:
# Using pip (Python package installer)
pip install awscli
# On Linux, using package manager
sudo apt-get install awscli # For Debian/Ubuntu
sudo yum install aws-cli # For RHEL/CentOS
Configuration
Configure AWS CLI:
aws configure
Follow the prompts to enter your AWS Access Key ID, Secret Access Key, default region, and output format.
Identity and Access Management (IAM)
Create User:
aws iam create-user --user-name UserName
Assign Policy to User:
aws iam attach-user-policy --user-name UserName --policy-arn arn:aws:iam::aws:policy/PolicyName
Here is a dedicated IAM Cheat Sheet.
Simple Storage Service (S3)
List Buckets:
aws s3 ls
Copy to S3:
aws s3 cp local-file s3://bucket/path/
Sync to S3:
aws s3 sync local-dir s3://bucket/path/
Here is a dedicated AWS S3 Cheat Sheet.
Elastic Compute Cloud (EC2)
Launch Instance:
aws ec2 run-instances --image-id ami-xxxxxxxx --instance-type t2.micro --key-name KeyPairName
List Instances:
aws ec2 describe-instances
Terminate Instance:
aws ec2 terminate-instances --instance-ids i-xxxxxxxx
Here is a dedicated AWS EC2 Cheat Sheet.
Relational Database Service (RDS)
Create RDS Instance:
aws rds create-db-instance --db-instance-identifier DBInstanceName --engine mysql --db-instance-class db.t2.micro --master-username MasterUsername --master-user-password MasterUserPassword
List RDS Instances:
aws rds describe-db-instances
Delete RDS Instance:
aws rds delete-db-instance --db-instance-identifier DBInstanceName --skip-final-snapshot
Lambda
Create Lambda Function:
aws lambda create-function --function-name MyFunction --runtime python3.8 --handler index.handler --role arn:aws:iam::account-id:role/execution_role --zip-file fileb://function.zip
Invoke Lambda Function:
aws lambda invoke --function-name MyFunction --payload '{"key1": "value1", "key2": "value2"}' output.txt
Here is a dedicated AWS Lambda Cheat Sheet.
Virtual Private Cloud (VPC)
Create VPC:
aws ec2 create-vpc --cidr-block 10.0.0.0/16
Create Subnet:
aws ec2 create-subnet --vpc-id vpc-id --cidr-block 10.0.0.0/24
Create Security Group:
aws ec2 create-security-group --group-name MySecurityGroup --vpc-id vpc-id
CloudFormation
Create Stack:
aws cloudformation create-stack --stack-name MyStack --template-body file://template.json --parameters ParameterKey=Key,ParameterValue=Value
Describe Stacks:
aws cloudformation describe-stacks
Delete Stack:
aws cloudformation delete-stack --stack-name MyStack
Best Practices
- Tag Resources:
- Tagging helps in resource organization and cost tracking.
- Use AWS CLI Profiles:
- Configure named profiles for different AWS accounts or roles.
- Enable MFA:
- Enable Multi-Factor Authentication for added security.
- Encrypt Data:
- Use encryption for sensitive data in transit and at rest.
- Monitor with CloudWatch:
- Set up CloudWatch Alarms for monitoring resources.
This cheat sheet provides a quick reference for common AWS commands and practices. Always refer to the official AWS documentation for detailed information on services and best practices.