Accessing AWS from CLI
Task 3 at Arth for accesing AWS from CLI
Task Description:
- Create a key pair
- Create a security group
- Launch an instance using the created key pair and security group
- Create an EBS volume of 1GB
- Attach the created EBS volume with the instance created prevoiusly.
To solve the above problem we must firstly install AWSCLI from the internet over our machine.
Then we have to run the command
aws configure
This command is used to set the user and password using the AWS Access Key ID and AWS Secret Access Key provided at the time of creating the IAM user
We can get help for any command using
aws help aws <command> help aws <command> <subcommand> help
- To create a key pair we use the command
aws ec2 create-key-pair --key-name awscli-key
2. Creating a security group
aws ec2 create-security-group --group-name AWSCLI --description "Security group created by CLI"
3. Launching the instance using the key pair and security group created
aws ec2 run-instances --image-id ami-0a54aef4ef3b5f881 --count 1 --instance-type t2.micro --key-name awscli-key --security-groups AWSCLI
4. Create an EBS volume of 1 GB
aws ec2 create-volume --availability-zone us-east-2c --size 1 --volume-type gp2
5. Connect the EBS to ithe instance created earlier.
aws ec2 attach-volume --volume-id vol-0883a84c4a3a65960 --instance-id i-02ae91e27033e7686 --device /dev/sdf
Now that all the all the steps have been done we can cross-check it from the WebUI
- Created Security Group
2. Instance created
3. EBS volume that was created and connected to the instance
From following these steps we can launch a instance from newly created security groups and key pair that attach an external storage with it using the Command Line Interface.