AWS CLI EC2 Setup

Here is an easy 7-Steps setup for EC2 using the CLI

During this entire procedure I only referred to the AWS documentation by the use of their help command.

Download the AWS CLI MSI installer for Windows (64-bit):

Then open cmd and then type aws help to see the list of services available and also how to type the commands down.

  1. So first step is to configure the user for that we first have to go to AWS and create an IAM User with Programmatic Access
CLI User with Programmatic Access

Then the User will be created and then we will get the Access key ID & Secret access Key.

User Created

2. Then we can configure AWS in our CLI by the command aws configure

So now we are ready to use the Services.

3. Lets first create a key-pair in EC2 by using the command aws ec2 create-key-pair — key-name <key name>

Key-Pair Created Successfully

4. Then lets create a security group by using the command aws ec2 create-security-group — group-name <name> — description <desc>

Security Group Created

5. Now lets finally run/launch our instance. For that we can we can use the command aws ec2 run-instances image-id <Image ID of the OS we want> — instance-type <ID of the type of an image> — key-name <Name of our key-pair> — security-groups <Security Group Name>

Instance Create

6. Now we will create an EBS Volume, for that we use the command aws ec2 create-volume — availability-zone <Availability Zone> — size <Size in GiB> NOTE: Availabilty Zone of the EBS should be same as that of the instance.

EBS Volume Created

7. Now the final step is to attach this volume to the instance that we created for that we use the command aws ec2 attach-volume — device <Device Name> — volume-id <EBS’s Volume ID>

Volume Successfully Attached

That’s it guys! Thanks for reading😊

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store