Connecting to AWS Services from Command Line
This guide provides step-by-step instructions for connecting to AWS services from the command line.
Hafeez Baig
44 steps
4 minutes
Amazon Web Services
Refer to the following guide to learn how to use IAM in the cloud\ <https://scribehow.com/shared/Creating_an_IAM_User_and_User_Group_in_AWS_Management_Console__hWNiiXlcRJKFqYZZEJD-cg>
1
Sign in to **AWS Management Console** as an **IAM User** **Pre-requisite** - Ensure you have selected the AWS region closest to your location\ For this guide, we will be using us-east-2 (Ohio) as a preferred choice
2
Type **IAM** in the search bar and click on **IAM** to view the IAM Dashboard
**What is IAM in AWS?** IAM (Identity and Access Management) in AWS is a web service that enables you to manage access to AWS resources securely. It allows you to control who is authenticated (signed in) and authorized (has permissions) to use resources within your AWS account.
3
On the **IAM Dashboard,** click on the **User groups** on the left bar
4
**User groups** wizard will open, click on the Group name **Operations**
Refer to this guide to learn how to create an Operations User group\ <https://scribehow.com/shared/Creating_an_Operations_IAM_User__5JyMzA1rRUmvp81UmVh3gA>
5
**Operations** wizard will open, scroll the page and click on the **Permissions** tab
6
On the right side click on the **Add permissions** button and select the **Attach policies** option
7
**Attach permission policies to Operations** wizard will open, select the Policy name **AdministratorAccess** from the list
**What is AdministratorAccess policy?** The AdministratorAccess policy in AWS grants unrestricted access to all AWS services and resources within an account. It should be used cautiously and only assigned to trusted users who require full control over all resources.
8
Scroll the page and click on the **Attach policies** button
9
Policies attached to this user group
Congratulations on attaching the AdministratorAccsess policy to the Operations user group!
10
On the IAM dashboard, click on the **Users** from the left bar
11
**Users** wizard will open, click on the User name **in28minutes-ops-user**
12
**in28minutes-ops-user** wizard will open, scroll to the **Summary** section and click on the **Create access key** link
13
**Access key best practices & alternatives** wizard will open, select the option **Command line Interface (CLI)**
**What is Command Line Interface CLI?** The Command Line Interface (CLI) is a text-based interface for interacting with a computer program or operating system through typed commands, offering efficiency and automation capabilities compared to graphical interfaces.
14
Scroll the page and tick the **Confirmation** section
15
Click on the **Next** button on the right side
16
**Set description tag** wizard will open, give the **Description tag value** as **AWSservicefromCLI**
17
Click on the **Create access key** button on the right side
18
Access key created
**What is AccessKey?** An Access key in AWS consists of an Access Key ID and a Secret Access Key. It's used for authentication and authorization to access AWS services programmatically.
19
Login to the AWS Management Console in the Incognito window with **in28minutes-ops-user** IAM user
20
Type **EC2** in the search bar and click on **EC2** to view the EC2 Dashboard
21
On the EC2 dashboard click on **Instances** from the left bar to view the EC2 instances
22
Select the Instance Name **First EC2 Instance**
23
Click on the **Connect** button on the top right corner
24
**Connect to instance** wizard will open, click on the **EC2 Instance Connect** tab and select the option Connect using **EC2 Instance Connect**
25
Scroll the page and click on the **Connect** button
26
On the **EC2 Instance Connect** page, type the command [[aws configure ]]in the terminal and press enter
**What is**`aws configure`**command?** The `aws configure` command sets up configuration settings for the AWS Command Line Interface (CLI), including access credentials, default region, and output format.
27
Come back to the **Retrieve access keys** page and copy the **Access key**
28
Paste the copied AWS Access Key in the terminal
29
Come back to the **Retrieve access keys** page and copy the **Secret access key**
30
Paste the copied **Secret access Key** in the terminal
31
Provide the region name as **us-east-2**
32
Type the command [[aws s3 ls]] in the terminal
**What is**`aws s3 ls`**command?** The `aws s3 ls` command lists objects (files and folders) in an Amazon S3 bucket.
33
All the buckets created in the **us-east-2** region are listed
34
Type the command [[aws s3 ls my-aws--bucket-in28minutes]] in the terminal
35
All the objects present in the **aws s3 ls my-aws-bucket-in28minutes** are listed
36
Type the command [[aws s3 ls my-aws--bucket-in28minutes/2030]] in the terminal
37
Moving into the 2030 object directory
38
To deactivate and delete the Access key, come back to the **Retrieve access keys** wizard tab
39
Scroll the page and click on the **Done** button
40
On the IAM dashboard, scroll to the **Access keys** section
41
On the right side click on the **Actions** dropdown button and select the option **Delete**
42
**Delete** wizard will open, click on the **Deactivate** button
43
Provide the **Access Key ID** in the input text field to confirm deletion and click on **Delete** button
44
Access key deleted
Congratulations on completing this lab and Connecting to AWS Services from Command Line! Well done!