Wednesday, July 31, 2019
AWS Command Line Interface (CLI) commands
$ pip install aws-shell
$ aws help
$ aws s3 help
$ aws s3 mb help
$ aws configure
$ aws configure list
AWS CLI Command Completer
1.) $ PATH=/usr/local/aws/bin:$PATH
2.) $ complete -C '/usr/local/aws/bin/aws_completer' aws
3.) Test it works: aws s3 M TAB
4.) MB or MV
What it does: Enables command completion for the AWS CLI, enter a partial command and press the Tab key to see the available commands. Add it to your ~/.bashrc
Why it's cool: Great for when you can't quite remember the name of a command, also good for exploring the CLI without reading the documentation!!!
What it does: Enables command completion for the AWS CLI, enter a partial command and press the Tab key to see the available commands. Add it to your ~/.bashrc
Why it's cool: Great for when you can't quite remember the name of a command, also good for exploring the CLI without reading the documentation!!!
S3 List Buckets
$ aws s3 ls
What it does: Lists out the buckets in your AWS.
Why it's cool: It is one of the simplest commandsto test if the CLI is working. You type in and it will spit out a list of all your buckets in your AWS account.
Copy a File From One S3 Bucket to Another S3 Bucket
What it does: Lists out the buckets in your AWS.
Why it's cool: It is one of the simplest commandsto test if the CLI is working. You type in and it will spit out a list of all your buckets in your AWS account.
Copy a File From One S3 Bucket to Another S3 Bucket
aws s3 cp s3://source-bucket/test.txt s3://destination-bucket/ --storage-class REDUCED_REDUNDANCY
What it does: The cp command specifies copy and, as can be seen, the storage class of REDUCED_REDUNDANCY has been specified for the storage of the file in the destination bucket.
Why it's cool: If you are copying a large filethen make sure to specify the required storage class at the time of the copy as this will save time. Changing the storage class of a large file in S3 can take a while so it's quickest to do so at the time of the creation of the file.
Sync S3 with Another Location
What it does: The cp command specifies copy and, as can be seen, the storage class of REDUCED_REDUNDANCY has been specified for the storage of the file in the destination bucket.
Why it's cool: If you are copying a large filethen make sure to specify the required storage class at the time of the copy as this will save time. Changing the storage class of a large file in S3 can take a while so it's quickest to do so at the time of the creation of the file.
Sync S3 with Another Location
aws --region us-east-2 s3 sync ./new-stuff s3://my-awesome-bucket --delete
What it does: Syncs S3 and the folder of your choice. Because we use the delete marker, this will delete any objects in the destination bucket that are not in the source bucket.
Why it's cool: If you have bucket or files that you want to be mirrored in S3, this command does exactly that. It mirrors two locations, like twins.
Delete an S3 Bucket and all its Contents
aws s3 rb s3://bucket-name –-force
What it does: This will delete the bucket in its entirety, very quickly.
Why it's cool: If you have to ever had to delete a substantial number of items in S3, you know that this can be a little time consuming. Not anymore !!!
Instances that are currently stopped
aws ec2 describe-instances --filters Name=instance-state-name,Values=stopped
What it does: This command will describe all of your stopped instances.
Why it's cool: Shows the reason they were stopped.
"StateReason":{"Message":"Client.UserInitiatedShutdown:User initiated shutdown",
"Code":"Client.UserInitiatedShutdown"
}
History for m1.xlarge Instances for a particular day
aws ec2 describe-spot-price-history --instance-types m1.xlarge --start-time 2019-03-17T07:08:09 --end-time 2019-03-18T08:09:10
What it does: Returns the Spot prices of the instance types within the time range that you specified and the time when the price changed.
Why it's cool: Great for researching the historical cost of Spot instances before you go ahead and bid. You can also narrow the results by referencing a particular AZ, e.g.
--availability-zone eu-west-1c
List of all your Key Pairs
What it does: Syncs S3 and the folder of your choice. Because we use the delete marker, this will delete any objects in the destination bucket that are not in the source bucket.
Why it's cool: If you have bucket or files that you want to be mirrored in S3, this command does exactly that. It mirrors two locations, like twins.
Delete an S3 Bucket and all its Contents
aws s3 rb s3://bucket-name –-force
What it does: This will delete the bucket in its entirety, very quickly.
Why it's cool: If you have to ever had to delete a substantial number of items in S3, you know that this can be a little time consuming. Not anymore !!!
Instances that are currently stopped
aws ec2 describe-instances --filters Name=instance-state-name,Values=stopped
What it does: This command will describe all of your stopped instances.
Why it's cool: Shows the reason they were stopped.
"StateReason":{"Message":"Client.UserInitiatedShutdown:User initiated shutdown",
"Code":"Client.UserInitiatedShutdown"
}
History for m1.xlarge Instances for a particular day
aws ec2 describe-spot-price-history --instance-types m1.xlarge --start-time 2019-03-17T07:08:09 --end-time 2019-03-18T08:09:10
What it does: Returns the Spot prices of the instance types within the time range that you specified and the time when the price changed.
Why it's cool: Great for researching the historical cost of Spot instances before you go ahead and bid. You can also narrow the results by referencing a particular AZ, e.g.
--availability-zone eu-west-1c
List of all your Key Pairs
aws ec2 describe-key-pairs --region us-west-1
What it does: Returns the names of all the key pairs you have configured in the specified region.
Why it's cool: Great for anyone who keeps forgetting the name of their active key pairs when logging into EC2 instances!!!
Describe your EC2 instances in Another Account
What it does: Returns the names of all the key pairs you have configured in the specified region.
Why it's cool: Great for anyone who keeps forgetting the name of their active key pairs when logging into EC2 instances!!!
Describe your EC2 instances in Another Account
aws ec2 describe-instances --profile production
What it does: Describes your EC2 instances from the profile called "production". You can configure the CLI to have multiple profiles (i.e. have multiple AWS accounts).
Why it's cool: The AWS CLI doesn't just work in one account,it works in as many accounts as you want to configure. By using the --profile option, you can query any account youlike from the same command line interfaces. So you could have a "Dev" profile and a "production" profile.
$ aws configure --profile production
Retrieve Information About IAM Users
aws iam get-user
What it does: Retrieves information about the specified IAM user, including the user's creation date, path, unique ID, and ARN. If you do not specify a user name, it returns the details of the user whose credentials you used to run the command.
Why it's cool: Great for quickly getting information about IAM users or confirming which IAM user your AWS CLI is configured to use!!!
Generate a Secure Password
What it does: Describes your EC2 instances from the profile called "production". You can configure the CLI to have multiple profiles (i.e. have multiple AWS accounts).
Why it's cool: The AWS CLI doesn't just work in one account,it works in as many accounts as you want to configure. By using the --profile option, you can query any account youlike from the same command line interfaces. So you could have a "Dev" profile and a "production" profile.
$ aws configure --profile production
Retrieve Information About IAM Users
aws iam get-user
What it does: Retrieves information about the specified IAM user, including the user's creation date, path, unique ID, and ARN. If you do not specify a user name, it returns the details of the user whose credentials you used to run the command.
Why it's cool: Great for quickly getting information about IAM users or confirming which IAM user your AWS CLI is configured to use!!!
Generate a Secure Password
aws secretsmanager get-random-password
What it does: Generates a complex password.
Why it's cool: Rather than cranking up that password manager or searching for a site to generate a password for you, just use this command to get back a long, complex password suitable for any account or service.
Validate the Content on a CloudFront Distribution
What it does: Generates a complex password.
Why it's cool: Rather than cranking up that password manager or searching for a site to generate a password for you, just use this command to get back a long, complex password suitable for any account or service.
Validate the Content on a CloudFront Distribution
aws cloudfront create-invalidation --distribution-id ABC123 --paths /*
What it does: Clears the cache on your CloudFront distribution so that all your new content is immediately available.
Why it's cool: No more worrying about TTL and old content. The viewers of your content can see the latest and greatest!!!
Validate a CloudFormation Template Before Upload
aws cloudformation validate-template --template-body file://sampletemplate.json
What it does: Validates your CloudFormation template before deploying to CloudFormation.
Why it's cool: It saves you time by ensuring you have a properly structured template.
Generate a Custom Narration of a Text
aws polly synthesize-speech --output-format mp3 --text "Hello there" --voice-id Brian hello.mp3
What it does: Creates a text-to-speech narration of text in MP3 format.
Why it's cool: Maybe you want to speech-enable your BASH script to provide positive supportive messages during your next production build. Or maybe you want to embarass the person who broke the build over the intercom :-)
What it does: Clears the cache on your CloudFront distribution so that all your new content is immediately available.
Why it's cool: No more worrying about TTL and old content. The viewers of your content can see the latest and greatest!!!
Validate a CloudFormation Template Before Upload
aws cloudformation validate-template --template-body file://sampletemplate.json
What it does: Validates your CloudFormation template before deploying to CloudFormation.
Why it's cool: It saves you time by ensuring you have a properly structured template.
Generate a Custom Narration of a Text
aws polly synthesize-speech --output-format mp3 --text "Hello there" --voice-id Brian hello.mp3
What it does: Creates a text-to-speech narration of text in MP3 format.
Why it's cool: Maybe you want to speech-enable your BASH script to provide positive supportive messages during your next production build. Or maybe you want to embarass the person who broke the build over the intercom :-)
Translate from One Language to Another
aws translate translate-text \
--text "Keep Being Awesome" \
--source-language-code EN \
--target-language-code FR
What it does: Translates text from a source language to a target language through the command line.
Why it's cool: Quickly translate text from the command line --- suitable for automation scripts where you might want to enable localized output or logging.
Detect the Sentiment in a String of Text
aws comprehend detect-sentiment --text 'This sure is helpful' --language-code en
What it does: Detects the sentiment in a string of text
Why it's cool: It can tell you if a string of text is positive, negative or neutral in those situations that you can't figure out.
What it does: Detects the sentiment in a string of text
Why it's cool: It can tell you if a string of text is positive, negative or neutral in those situations that you can't figure out.
Tuesday, July 30, 2019
AWS services: Summary of each
Storage
Amazon Simple Storage Services (S3)
Amazon Elastic File System (EFS)
Amazon Elastic Block Storage (EBS)
Compute
AWS Lambda
Amazon EC2 Auto Scaling
VMware Cloud on AWS
Amazon EC2 Container Service for Kubernetes
Amazon EC2
AWS Fargate
Amazon EC2 Container Service
Productivity, Desktop & App Streaming
Amazon WorkSpaces
Amazon AppStream 2.0
Alexa for Business
Management Tools
Amazon CloudWatch
AWS CloudFormation
AWS Auto Scaling
AWS CloudTrail
Networking & Content Delivery
Amazon Route 53
Amazon VPC
Amazon CloudFront
Analytics
Amazon Redshift
AWS Data Pipeline
Amazon QuickSight
Amazon EMR
Amazon Kinesis
Amazon Athena
AWS Glue
Amazon CloudSearch
Amazon Elasticsearch Service
Machine Learning
Amazon Comprehend
Amazon Rekognition
Amazon Transcribe
Apache MXNet on AWS
AWS DeepLens
Amazon Machine Learning
Amazon Translate
Amazon Polly
Amazon SageMaker
AWS Deep Learning AMIs
Amazon Lex
TensorFlow on AWS
Developer Tools
AWS CodeStar
AWS CodeBuild
Developer Tools
AWS CodeCommit
AWS CodeDeploy
AWS CodePipeline
AWS Cloud9
Database
Amazon ElastiCache
Amazon DynamoDB
Amazon Redshift
Amazon RDS
Amazon Aurora
Amazon Simple Storage Services (S3)
Amazon Elastic File System (EFS)
Amazon Elastic Block Storage (EBS)
Compute
AWS Lambda
Amazon EC2 Auto Scaling
VMware Cloud on AWS
Amazon EC2 Container Service for Kubernetes
Amazon EC2
AWS Fargate
Amazon EC2 Container Service
Productivity, Desktop & App Streaming
Amazon WorkSpaces
Amazon AppStream 2.0
Alexa for Business
Management Tools
Amazon CloudWatch
AWS CloudFormation
AWS Auto Scaling
AWS CloudTrail
Networking & Content Delivery
Amazon Route 53
Amazon VPC
Amazon CloudFront
Analytics
Amazon Redshift
AWS Data Pipeline
Amazon QuickSight
Amazon EMR
Amazon Kinesis
Amazon Athena
AWS Glue
Amazon CloudSearch
Amazon Elasticsearch Service
Machine Learning
Amazon Comprehend
Amazon Rekognition
Amazon Transcribe
Apache MXNet on AWS
AWS DeepLens
Amazon Machine Learning
Amazon Translate
Amazon Polly
Amazon SageMaker
AWS Deep Learning AMIs
Amazon Lex
TensorFlow on AWS
Developer Tools
AWS CodeStar
AWS CodeBuild
Developer Tools
AWS CodeCommit
AWS CodeDeploy
AWS CodePipeline
AWS Cloud9
Database
Amazon ElastiCache
Amazon DynamoDB
Amazon Redshift
Amazon RDS
Amazon Aurora
VPC: Web server and database server implementation
Incorporated two Web servers in a Public network and two Database servers in a Private network to illustrate a Virtual Public Cloud implementation.
Virtual Private Cloud
Your VPCs
Name: VPC-1
VPC ID: vpc-241e8243
State: Available
IPv4 CIDR: 10.50.0.0/16
IPv6 CIDR:
DHCP Options Set: dopt-18638e7f
Route table: rtb-f603cf91
Network ACL: acl-f8aae59f
Tenancy: Default
Default VPC: No
Subnets
Name: VPC-1-Public
Subnet ID: subnet-b9cf7ede
VPC: vpc-241e8243 | VPC-1
IPv4 CIDR: 10.50.1.0/24
Name: VPC-1-Private
Subnet ID: subnet-bccf7edb
VPC: vpc-241e8243 | VPC-1
IPv4 CIDR: 10.50.2.0/24
Route Tables
Name:
Route Table ID: rtb-f60c3f91
Explicitly Associated with: 0 Subnets
VPC: vpc-241e8243 | VPC-1
Name:
Route Table ID: rtb-f20c3f95
Explicitly Associated with: 1 Subnet
VPC: vpc-241e8243 | VPC-1
Name: Route-Private-NAT
Route Table ID: rtb-1afdce7d
Explicitly Associated with: 1 Subnet
VPC: vpc-241e8243 | VPC-1
Internet Gateways
Name: Internet-Gateway-1
ID: igw-34052450
State: Attached
VPC: vpc-241e8243 | VPC-1
Elastic IPs
Elastic IP: 52.27.162.65
Allocation ID: eipalloc-338b8954
Instance: -
Private IP address: 10.50.2.26
Scope: vpc
Public DNS: eipassoc-46bc293c
Network Interface ID: eni-36d1fd46
NAT Gateways
NAT Gateway: nat-0e38dd76ef07367f2
Status: Available
Elastic IP Address: 52.27.162.65
Private IP Address: 10.50.2.26
Network Interface ID: eni-36d1fd46
VPC: vpc-241e8243
Subnet: subnet-bccf7edb
Security
Network ACLs
Name:
Network ACL ID: acl-f8aae59f
Associated With: 2 Subnets
Default: Yes
VPC: vpc-241e8243 | VPC-1
Security Groups
Name tag:
Group ID: sg-5f452c27
Group Name: default
VPC: vpc-241e8243 | VPC-1
Description: default VPC security group
Inbound Rules:
Type Protocol Port Range Source
ALL Traffic ALL ALL sg-5f452c27
Outbound Rules:
Type Protocol Port Range Source
ALL Traffic ALL ALL 0.0.0.0/0
Name tag: SG-Database-1
Group ID: sg-52b0d92a
Group Name: SG-Database-1
VPC: vpc-241e8243 | VPC-1
Description: Security group for Database servers
Inbound Rules:
Type Protocol Port Range Source
ALL Traffic ALL ALL sg-5f452c27
Outbound Rules:
Type Protocol Port Range Source
ALL Traffic ALL ALL 0.0.0.0/0
Name tag: SG-Management
Group ID: sg-7ab3da02
Group Name: SG-Management
VPC: vpc-241e8243 | VPC-1
Description: Management
Inbound Rules:
Type Protocol Port Range Source
SSH(22) TCP(6) 22 0.0.0.0/0
Outbound Rules:
Type Protocol Port Range Source
SSH(22) TCP(6) 22 sg-52b0d92a
SSH(22) TCP(6) 22 sg-acb1d8d4
SSH(22) TCP(6) 22 sg-fc82eb84
Name tag: SG-NAT
Group ID: sg-fc82eb84
Group Name: SG-NAT
VPC: vpc-241e8243 | VPC-1
Description: Security Group for NAT
Inbound Rules:
Type Protocol Port Range Source
SSH(22) TCP(6) 22 sg-7ab3da02
HTTP(80) TCP(6) 80 sg-52b0d92a
HTTPS(443) TCP(6) 443 sg-52b0d92a
Outbound Rules:
Type Protocol Port Range Source
HTTP(80) TCP(6) 80 0.0.0.0/0
HTTPS(443) TCP(6) 443 0.0.0.0/0
Name tag: SG-WebServer-1
Group ID: sg-acb1d8d4
Group Name: SG-WebServer-1
VPC: vpc-241e8243 | VPC-1
Description: Security Group for Web servers
Inbound Rules:
Type Protocol Port Range Source
SSH(22) TCP(6) 22 sg-7ab3da02
HTTP(80) TCP(6) 80 0.0.0.0/0
HTTPS(443) TCP(6) 443 0.0.0.0/0
Outbound Rules:
Type Protocol Port Range Source
HTTP(80) TCP(6) 80 0.0.0.0/0
HTTPS(443) TCP(6) 443 0.0.0.0/0
MySQL/Aurora(3306) TCP(6) 3306 sg-52b0d92a
IAM: Identity and Access Management
AWS Identity and Access Management (IAM) is a web service that helps you securely control to resources on the AWS for your users. You can use IAM to control who can use your AWS resources(authentication) and what resources they can use and in what manner(authorization and privileges).
IAM: Recommended Critical security practices
Recommendations:
* Lock away your AWS account root access keys
The access key you get or create on AWS has an access key ID and secret access key. This has superuser, unrestricted privileges and opens up full access to all your resources for all AWS services, including your billing information. No restrictions can be placed around your AWS account access key. Hence you need to protect your AWS account access key like you protect your credit card information or any other sensitive secret. Do these
a) Do not create an AWS account access key unless you absolutely need it. Instead of that, use your account EMail ID and password to sign in on the AWS Management Console and create an IAM user for yourself such that it has administrative privileges.
b) It's a good idea to delete the access key for your AWS account. If you absolutely want to keep it, change it once every three months.
c) Never disclose your AWS account password or access keys to anyone. Do not embed your password in any of your applications.
d) Use a strong password to help protect account-level access to the AWS Management Console.
e) Enable AWS multi factor authentication (MFA) on your AWS account.
* Create individual IAM user IDs
Never use your AWS root account credentials to access AWS, and never, ever give your credentials to anybody else. Instead of that, create individual user IDs for those who need access to your AWS account. Also, create an IAM user ID for yourself, give that user administrative privileges, and use that IAM user ID for all that you work on.
Monday, July 29, 2019
Subscribe to:
Posts (Atom)

