Building Basic AWS Cloud Infrastructure using AWS CLI

Building Basic AWS Cloud Infrastructure using AWS CLI

TASK DESCRIPTION :

Create the following using AWS CLI:

  • Create a key pair
  • Create a security group
  • Launch an instance using the above created key pair and security group.
  • Create an EBS volume of 1 GiB.
  • The final step is to attach the above created EBS volume to the instance you created in the previous steps.

What is AWS CLI ?

No alt text provided for this image

The AWS Command Line Interface (CLI) is a unified tool to manage your AWS services. With just one tool to download and configure, you can control multiple AWS services from the command line and automate them through scripts.

To use AWS CLI, we need to download and install it in our system. For this practical, we'll use Version 2. After installing, to verify if it is successfully installed or not we can check its version.

No alt text provided for this image

Before starting, we need aws Access key and Secret key for configuration.

  • To, get them we need to go to our AWS account from AWS Web Console. Then go to “IAM” service => click on “Users” => then click on “Add User” and create one user.
  • Then click on “Programmatic access” and then it'll be giving us “Access key” and “Secret key”.
No alt text provided for this image

We use aws configure command to setup the AWS CLI. We need to provide Access key and Secret key of IAM user for authentication also we have to mention the region name and output format.

No alt text provided for this image

There is no need to remember the commands, we can refer to the help.

No alt text provided for this image

We can easily see all the commands available for EC2 on CLI. Let's Start...

Step-1 : Create a key pair

aws ec2 create-key-pair --key-name awskey
No alt text provided for this image
No alt text provided for this image

Step-2 : Create a security group

aws ec2 create-security-group --group-name AWSscgroup --description "My Aws Cli security group" --vpc-id vpc-441de639
No alt text provided for this image
No alt text provided for this image

Now we need to add inbound rules.

aws ec2 authorize-security-group-ingress --group-name AWSscgroup --protocol tcp --port 22 --cidr 0.0.0.0/0
No alt text provided for this image
No alt text provided for this image

Step-3 : Launch an instance using the above created key pair and security group.

aws ec2 run-instances --image-id ami-038f1ca1bd58a5790 --instance-type t2.micro --key-name awskey --security-group-ids sg-0a298a35e6ee44eb7 --subnet-id subnet-946b98a5 --count 1 --tag-specifications=ResourceType=instance,Tags=[{Key=Name,Value=Cli-Instance}]
No alt text provided for this image
No alt text provided for this image

Step-4 : Create an EBS volume of 1 GiB.

aws ec2 create-volume --volume-type gp2 --size 1 --availability-zone us-east-1e --tag-specifications=ResourceType=volume,Tags=[{Key=Name,Value=myEbs-cli}] 
No alt text provided for this image
No alt text provided for this image

Step-5 : Attach the above created EBS volume to the instance.

aws ec2 attach-volume  --volume-id vol-004c12b22254c15ac  --instance-id i-02303356cdfd40748  --device /dev/sdf
No alt text provided for this image
No alt text provided for this image

We can also verify this by checking the disks attached to the instance.

No alt text provided for this image


***** THANK YOU FOR READING!! *****


要查看或添加评论,请登录

Khushi Garg的更多文章

  • Industrial Use-cases of Ansible

    Industrial Use-cases of Ansible

    What is Ansible? Ansible is an automation software tool that provides simple but powerful Automation for cross-platform…

  • Benefits that MNC’s are getting from AI/ML

    Benefits that MNC’s are getting from AI/ML

    What is Artificial Intelligence? Artificial Intelligence is the simulation of human intelligence to the machine that is…

    2 条评论
  • Setting up Python on Docker Container

    Setting up Python on Docker Container

    In the following article we're going to set up Python Interpreter and run python code on a Docker container. For this…

    2 条评论
  • Configuring HTTPD Server on Docker Container

    Configuring HTTPD Server on Docker Container

    In the following article we are going to configure the HTTPD server on the Docker container. In this practical we're…

  • KUBERNETES - A Container Management tool

    KUBERNETES - A Container Management tool

    What is Kubernetes ? Kubernetes is an open-source Container-Orchestration system software for automating Deployment…

    2 条评论
  • DOCKER AUTOMATED USING ANSIBLE

    DOCKER AUTOMATED USING ANSIBLE

    To configure and start Docker services and configure Apache Webserver on it using Ansible playbook. TASK DESCRIPTION :…

    4 条评论
  • UNILEVER Case Study - AWS

    UNILEVER Case Study - AWS

    This Article shows the case study of Global Cloud Leader that is Amazon Web Services ( AWS ) Cloud . In this we'll see…

    2 条评论
  • "BIG DATA": Problems, solutions and its management!

    "BIG DATA": Problems, solutions and its management!

    "Over 2.5 quintillion bytes of data is created every single day, and it’s only going to grow from there.

    5 条评论
  • Deploying WordPress on Google Cloud Platform by integrating various GCP services..

    Deploying WordPress on Google Cloud Platform by integrating various GCP services..

    Hello Readers! This is my Google Cloud Platform task by integrating all those things which I've learnt in my two days…

    5 条评论
  • Google Cloud Platform (GCP)

    Google Cloud Platform (GCP)

    This article talks about all the services in Google Cloud Platform which I learnt from 2 days of workshop organised by…

社区洞察

其他会员也浏览了