Launch an AWS EC2 instance and attach EBS volume using Terraform

Tanmay Chauhan
2 min readJul 15, 2021

--

Task Description:

  1. Create a key pair
  2. Create a security group
  3. Launch an instance using the above created key pair and security group.
  4. Create an EBS volume of 1 GB.
  5. The final step is to attach the above created EBS volume to the instance you created in the previous steps.

Step 1:- Write a terraform code for all the above steps and save the code using extention .tf

Step 2:- Now open the command prompt, go to the folder where the code is been stored and run terraform init command to initialize the plugins.

Step 3: Now run the terraform apply — —auto-approve command to build the infrastructure in AWS according to our plan. we can view our plan using terraform plan command.

Now our EC2 instance has been created with key-pair and security group and also 1 GB of EBS volume has been created and attached to our EC2 instance. We can check it by opening AWS website.

Github URL:- https://github.com/Tanmay-19/terraform-aws-instance-launch-Task2

Thank you for reading….!!!!!

--

--

No responses yet