Deploying Infrastructure on AWS using AWS-CLI
Samarth Pant
Information Technology Analyst @ TCS | Contextual Master | OpenTofu | Terraform |
Description:
?? 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 and attach it to the instance created above.
AWS CLI:
The AWS Command Line Interface (CLI) is a unified tool to manage your AWS services. With just one tool to download and configure, you can control multiple AWS services from the command line and automate them through scripts.
STEPS PERFORMED:
- Create a key-pair
The command to create a key pair is:
aws ec2 create-key-pair --key-name myawsclikey
- Create a security group
The command to create a security group is:
aws ec2 create-security-group --description "my_aws_cli_sg" --group-name myclisg --vpc-id vpc-758b931d
- Launch an instance using the above created key pair and security group
The command to launch an instance using the above-created key-pair and security group is:
aws ec2 run-instances --image-id ami-0e306788ff2473ccb --instance-type t2.micro --count 1 --security-group-ids sg-0bc4b183a4d635a63 --key-name myawsclikey --subnet-id subnet-3175037d
- Create an EBS volume of 1 GB and attach it to the instance created above
The command to create an EBS volume is:
aws ec2 create-volume --availability-zone ap-south-1b --size 1 --volume-type gp2
Command to attach created EBS volume to an instance is:
aws ec2 attach-volume --instance-id i-06b9b4c59734c3920 --volume-id vol-0c091c9da04ac6de2 --device /dev/sdh