~ Creating a New Key Pair
~ Creating a Security Group
~ Adding New Inbound Rules
~ Launch an Instance using above Key Pair and Security group
~ Adding Tags to the Instance launched
What is AWS CLI?
AWS Command Line Interface is a unified tool using which, we can manage and monitor all our AWS services from a terminal session on the client.
Although most AWS services can be managed through the AWS Management Console or via the APIs, there is a third way that can be very useful i.e. the Command Line Interface (AWS CLI). AWS has made it possible for Linux, MacOS, and Windows users to manage the main AWS services from a local terminal session’s command line
The Following Steps have been followed:
- Check weather AWS CLI is installed or not by aws — — version, if not install it.
- Now we need to configure aws by providing aws access key, secret key, subnet and file type. Command used :- aws configure
3. Creating a new key-pair. Command used :- aws ec2 create-key-pair — — key-name <key_name>
4. Create a security group. Command used :- aws ec2 create — security — group — — group-name <any_name> — — description <description_name>
5. Add inbound rules for security group. Command used :- aws ec2 authorize-security-group-ingress — -group-name <rule_name> — — protocol tcp — — port 22 — — cidr 0.0.0.0/0
6. Launch an ec2 instance using the above created key-pair and security group. Command used :- aws ec2 run-instances — —image-id <iso_image_id> — —count <number_of_instances> — —instance-type <type> — —key-name <key_name> — — security-group-ids <sg_id> — —subnet-id <id>
7. Add tags to the instance launched. Command used :- aws ec2 create-tags — — resources <instance_id> — —tags Key=<key_name>,Value=<value>
I hope this blog will help you to gain knowledge.