1. Create a key pair
2. Create a security group
3. Launch an instance using the above created key pair and security group.
4. Create an EBS volume of 1 GB.
5. The final step is to attach the above created EBS volume to the instance you created in the previous steps.
A brief Introduction to AWS:
AWS is a cloud computing service which provides cloud services for us. We can leverage all of the services of in AWS for creating our own things or improve the already existing things.
What is EC2?
EC2 is one of the services of AWS. EC2 stands for Elastic Compute Cloud. Elastic means we can increase or decrease the storage and other services in EC2.
What is EBS?
EBS is a service that provides storage volumes for the instances we have created. EBS stands for Elastic Block Storage. The storage devices we use now-a-days are called Block Devices. So, this service is called EBS.
Step-1: Create a Key Pair
- We need a key pair for entering into the instance through SSH. So, we have to create a key pair for launching a new instance.
- For creating a key pair, we need command :
aws ec2 create-key-pair — key-name task3key — profile task3
Here, I have created a key pair named ‘task3key’. We can check in AWS also for ensuring its creation.
Step -2: Create a security group
Security groups are very useful for permitting traffic into our instance. We can create a security group using the command:
aws ec2 create-security-group — group-name newsecgroup –description newsecuritygroup
You can set your own group name here. I have set ‘newsecgroup’
Now we got the new security group ID.
We can check whether new security group is created or not in the AWS.
Step -3: Launch a new instance with the created key pair and the security group
Now we have to launch a new instance using the key-pair ‘task3key’ and security group ‘newsecgroup’ we have created.
In Web UI, we can launch an instance easily. But in CLI, we have to gather the ids we want for creating a new instance. We need
• — image-id (Amazon Linux ID — ami-id)
• — instance-type (t2.micro — as it is available for free)
• — count (instance count — default would be 1)
• — subnet-id (select subnet id for the region you want to launch)
• — security-group-ids (id of the security group)
• — key-name (keypair name) for creating a new instance.
After we have gathered all of them, we are ready to launch our new Amazon Linux instance.
After entering all the details in the CLI, a new instance is created.
We can check whether new instance is created or not in the AWS with required details.
Step-4: Create an EBS volume of 1GiB and attach it to the newly created instance
We can create a volume of our own size. But, only 1 GiB is available in free tier account. So, let’s create a new volume of size 1 GiB in availability zone ap-south-1a.
command for launching a new volume:
aws ec2 create-volume — availability zone ap-south-1a — size 1
Step-5: attach the above created EBS volume to the instance you created in the previous steps
Now we have to attach it to the instance we have created. We have to provide
• — instance-id
• — volume-id
• — device (the device name ex: /dev/sdh) for attaching the volume to the instance
Now, the volume is attached to the instance we have created as I have provided the newly created instance’s id.
You can see in details of instance that the new volume is attached.