AWS with CLI
Amazon Web Services(AWS) is a cloud service from Amazon, which provides services in the form of building blocks, these building blocks can be used to create and deploy any type of application in the cloud.
AWS Command Line Interface(AWS CLI) is an open source tool that enables you to interact with AWS services using commands in your command-line shell. With minimal configuration, the AWS CLI enables you to start running commands that implement functionality equivalent to that provided by the browser-based AWS Management Console from the command prompt in your terminal program.
- 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 GB.
- The final step is to attach the above created EBS volume to the instance you created in the previous steps.
Environment setup for task
Step 1: Download and install AWS-CLI
For download AWS-CLI software please refer to this website. After installing we can check it using following command
Step 2: Configure AWS-CLI
Now, after successfully installing, we have to configure AWS-CLI with AWS IAM user credentials.
Now, moving forward to implement task.
Step 1: Create a key pair
A key pair, consisting, is a set of security credentials that you use to prove your identity when connecting to an EC2 instance. Command to create key-pair is as follows.
aws ec2 create-key-pair --key-name <KeyName>
Step 2: Create a security group
A security group acts as a virtual firewall for your EC2 instances to control incoming and outgoing traffic. Inbound and outbound rules control the incoming(to instance) and outgoing(from instance) traffic respectively.
Command to create security group.
aws ec2 create-security-group --description <GroupDescription> --group-name <GroupName>
Step 3: Launch an ec2-instance using the above created key pair and security group.
An Amazon EC2 instance is a virtual server in Amazon’s Elastic Compute Cloud (EC2) for running applications on the Amazon Web Services (AWS) infrastructure.
Command to launch instance.
aws ec2 run-instances --image-id <Image-id> --instance-type <InstanceType> --security-group-ids <SecurityGroup-id> --key-name <Key-pairName>
Step 4: Create an EBS volume of 1 GB.
An Amazon EBS volume is a durable, block-level storage device that you can attach to your instances.
aws ec2 create-volume --availablity-zone <ZoneName> --size <SizeNumber>
Step 5: Attaching the above created EBS volume to the instance you created in the previous steps.
This is final step of task. Command for attaching EBS volume to instance is:
aws ec2 attach-volume --device /<directory> --instance-id <instanceid> --volume-id <volumeid>
Here, we have completed task using AWS-CLI. Thanks for reading.