INTEGRATING AWS WITH CLI

Here,we will study how we can use AWS tools/services using Command Prompt/Command Line .In order to run AWS command on CLI we need to install an application on Windows called as “AWSCLIV2.msi”.Link

Then,to check whether it is installed or not, use the command-: “aws” in CLI.

  • >To login to AWS Console as an IAM user, use the command- “aws configure” .Then, Enter your credentials such as AWS Access Key ID and Secret Access Key.After that select the region name (by default it takes ap-south-1) and then Select output format which is by default JSON.
  • > To create a key-pair, we can use the command-: “aws ec2 create-key-pair --key-name <name>”.
  • >Now,if you want to create a Security Group,you can use the command:- “aws ec2 create-security-group --group-name< name> -- description< “ “>”. You can also use option called “--tag-specification” to assign tags to your Security Group and --vpc-id<ID> to create vpc id of security group .
  • >If you want to launch a new instance, then use the command-: “aws ec2 run-instances --image-id<ami-….> --instance-type<t2. ….> --count<no. of instances> --subnet-id<subnet- …> --security-group-ids<sg- …> --key-name <key-pair_name>”. If you don’t specify storage,it is by default considered as 8 GiB size.
  • >To create an EBS Volume,we have a command called -: “aws ec2 create-volume --availability-zone <zone> --size<(in GiB)>.Volume type is by default selected as “gp-2” if not specified.
  • > To attach the above created volume to an instance, we use command-: “aws ec2 attach-volume --instance-id<i- …> --volume-id<vol- …> --device<device_name>”.