Working With AWS CLI - 23rd May 2022 Notes
Working With AWS CLI - 23rd May 2022 Notes
Working With AWS CLI - 23rd May 2022 Notes
For example, we can use the script to deploy multiple resources without the need to
go through a complete configuration wizard each time.
1) Create AWS Account: In order to configure AWS CLI, an AWS account needs to be
created if you do not have one. Please register for the AWS account. The new AWS
account includes 12 months of free tier access.
2) Install AWS CLI: AWS CLI is available for Windows, MAC and Linux distribution of
OS.
b) MAC and Linux: Please follow these steps (execute below commands)
1) Access Key ID
2) Secret access key
-> We are going to store this information securely and will not share this
information.
-> Alternatively, CSV file download option is available, CSV file contains the
details.
-> Safely store the key or downloaded “CSV” file, as we will not be able to
retrieved Secret Access Key again.
-> Click on close and you will end up on the user dashboard. The newly created user
is available now.
Step1: Click on the demo user, the pertinent details corresponding to user will be
shown.
Permissions
Groups
Tags
Security Credentials
Access Advisor
Step3: Here we are seeing Access Key ID, which was recently created with status
marked as “Active”
Step4: In this case, the Access Key status provides an important security feature
to the administrators.
Step5: Now we have the user, therefore allowing us access to AWS resources
programmatically.
2) Before we can access the AWS resources using CLI (command-line interface), we
will need to configure the CLI.
$ aws configure
AWS Secret Access Key : Corresponding to the “AWS Access Key” selected
Step3: Next, we are going to run “aws s3 ls" (to display bucket lis)
$ aws s3 ls
Step4: After listing out the content of the existing bucket, let us try to create a
new s3 bucket using AWS CLI
$ aws s3 mb s3://ashokitbucket
Step6: Furthermore, let us try to create a bucket in a region other than the
default region for the CLI profile, in our case the default region is ‘us-east-1’
Step7: After the command has been executed, let us check, if the bucket has been
created and what is the region of the bucket.
or a tag key:
The above command will create a new key in the AWS named ashokitkey and pipe the
secret key directly to the location we specify, in this case, ashokitkey.pem.
Terminate an Instance
++++++++++++++++++++++
$ aws ec2 terminate-instances --instance-ids <instance-id>