
Hello Readers, I hope you all are doing so well. In this blog we will see that how we can set-up Instance in AWS using terraform. Before starting you must have Terraform, AWS CLI install on your machine and they both must be configure. So stay tuned with me.
SO LET’S GET START!!
It is easy to set-up Instance using terraform. In order to do so you should follow certain steps.
These are as follows:
STEP 1: Go the given https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/instance and copy the content from the terraform docs of aws_instance.
STEP 2: Now; Open your terminal and make one directory and under that directory make file named as Instance.tf, and paste the content that you have copied from the URL.
Run the following commands to do so :
cd Documents mkdir Terraform mkdir Instance nano Instance.tf

cat instance.tf

STEP 4: Remember you should have aws CLI in your local machine and then Configure your AWS by running the command:
aws configure
STEP 5: Make one more file named as provider.tf to give your credentials for AWS as:
provider "aws"{
region = "us-east-1"
access_key = "Your_Access_Key"
secret_key = "Your_Secret_Key"
}
STEP 6: Now run the following command :
terraform init

STEP 7: Now let’s plan it . Plan is basically you are creating anything and what exactly you will get as the result.
terraform plan


STEP 8: finally run the command given below to apply it. You will see your s3 bucket is creating after providing it the value as ‘Yes’.
terraform apply


STEP 9: Login into your AWS Console and search for service as Instance, you will see your Instance is created.

So , Yes we have successfully created our Instance using terraform in AWS.
Conclusion :
So, In this blog we have seen in some simple steps how we can create instance in AWS using terraform. Thanks for being with me till the end. If you find this blog helpful do share with your friends.
HAPPY LEARNING..!!!
Reference :
https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/instance