My FeedDiscussionsHeadless CMS
New
Sign in
Log inSign up
Learn more about Hashnode Headless CMSHashnode Headless CMS
Collaborate seamlessly with Hashnode Headless CMS for Enterprise.
Upgrade ✨Learn more
Creating instance in AWS using cli

Creating instance in AWS using cli

Devesh Bhardwaj's photo
Devesh Bhardwaj
·Mar 21, 2021·

6 min read

What is AWS-: AWS ( amazon web services ) is the cloud company owned by amazon inc. . They provide users cloud based services like launching instances on there pre-configured hardware .By this client doesn't need and physical system client just need to tell what type of service the need. AWS not only provide us service to create instances there are many other services that are provides by AWS some of them are-:

  1. AWS Elastic Cloud Compute (EC2)
  2. AWS s3 (Simple Storage Services)
  3. Amazon Virtual Private Cloud (VPC)
  4. Amazon Cloud Front
  5. Amazon Relation Database Services (RDS) Creating own key pair , Security Group ,EBS Volume and Launching EC2 instance on AWS using these-:

Steps to download aws cli : click on this link and download .msi file (for windows) and install this in your system.

To create own security groups ,Key Pair ,ebs volume we firstly need AWS account. Follow these steps to create AWS account.

  1. Go to https://aws.amazon.com/console/ and click my account and then click on AWS management console

1.jpg

  1. After that click on create new account and fill all details that are asking and at last provide your credit card details and create account.

2.jpg

  1. Now Login your account. Your console look like this.

3.jpg

Now we need access key and secret access key to login in cli using your account but be sure do not share your these details with anyone.

4.jpg

To login open cli and type

you see this type of output-:

5.jpg

Put all details there like access key ID and secret access key

after that you are successfully login in your cli using your aws account.

What is security group?

Security group acts as a virtual firewall for your EC2 instances to control incoming and outgoing traffic. If we don't specify a security group, Amazon EC2 uses the default security group. We can add rules to each security group that allow traffic to or from its associated instances Creating own security group-:

syntax-:

aws ec2 create-security-group --description --group-name [--vpc-id ] [--dry-run | --no-dry-run] [--cli-input-json | --cli-input-yaml] [--generate-cli-skeleton ] [--cli-auto-prompt ]

6.jpg

if we login in aws account we can see our newly created security key-:

7.jpg

Creating Key pair -:

Creates a 2048-bit RSA key pair with the specified name. Amazon EC2 stores the public key and displays the private key for you to save to a file. The private key is returned as an unencrypted PEM encoded PKCS#1 private key. If a key with the specified name already exists, Amazon EC2 returns an error.

syntax-:

   --key-name <value>
   [--dry-run | --no-dry-run]
   [--tag-specifications <value>]
   [--cli-input-json | --cli-input-yaml]
   [--generate-cli-skeleton <value>]
   [--cli-auto-prompt <value>]

8.jpg

9.jpg

Creating Elastic Block Storage volume-: what is ebs?

An Amazon EBS volume is a durable, block-level storage device that you can attach to your instances. After you attach a volume to an instance, you can use it as you would use a physical hard drive. EBS volumes are flexible.

syntax-:

— availability-zone <value>
[ — encrypted | — no-encrypted]
[ — iops <value>]
[ — kms-key-id <value>]
[ — outpost-arn <value>]
[ — size <value>]
[ — snapshot-id <value>]
[ — volume-type <value>]
[ — dry-run | — no-dry-run]
[ — tag-specifications <value>]
[ — multi-attach-enabled | — no-multi-attach-enabled]
[ — cli-input-json | — cli-input-yaml]
[ — generate-cli-skeleton <value>]
[ — cli-auto-prompt <value>]

10.jpg

11.jpg

Now lets Launch a instance and attach ebs volume in that...

[ — block-device-mappings <value>]
[ — image-id <value>]
[ — instance-type <value>]
[ — ipv6-address-count <value>]
[ — ipv6-addresses <value>]
[ — kernel-id <value>]
[ — key-name <value>]
[ — monitoring <value>]
[ — placement <value>]
[ — ramdisk-id <value>]
[ — security-group-ids <value>]
[ — security-groups <value>]
[ — subnet-id <value>]
[ — user-data <value>]
[ — additional-info <value>]
[ — client-token <value>]
[ — disable-api-termination | — enable-api-termination]
[ — dry-run | — no-dry-run]
[ — ebs-optimized | — no-ebs-optimized]
[ — iam-instance-profile <value>]
[ — instance-initiated-shutdown-behavior <value>]
[ — network-interfaces <value>]
[ — private-ip-address <value>]
[ — elastic-gpu-specification <value>]
[ — elastic-inference-accelerators <value>]
[ — tag-specifications <value>]
[ — launch-template <value>]
[ — instance-market-options <value>]
[ — credit-specification <value>]
[ — cpu-options <value>]
[ — capacity-reservation-specification <value>]
[ — hibernation-options <value>]
[ — license-specifications <value>]
[ — metadata-options <value>]
[ — count <value>]
[ — secondary-private-ip-addresses <value>]
[ — secondary-private-ip-address-count <value>]
[ — associate-public-ip-address | — no-associate-public-ip-address]
[ — cli-input-json | — cli-input-yaml]
[ — generate-cli-skeleton <value>]
[ — cli-auto-prompt <value>]

!! all value are required