Create EC2 using Terraform

Everton Araújo
2 min readAug 15, 2020
Terraform Logo

It might seem a little difficult at first, but Terraform came to facilitate the creation of code infrastructure (IaC).

Below I put this image of the AWS Console Manager is where we check the AMI.

AMI — Amazon Machine Image

Virtually everyone sees a lot of me editing codes using Vs code is a sensational tool and most of the world’s DevOps use it. For being light and fast and for being an application that has for Windows, Mac and Linux.

I recommend going to Tools and configuring Anton Kulikov’s Terraform plugin, Terraform Doc Snippets and Terraform AutoComplete. The latter is interesting and automatically assembles your code. When you press Crtl + Space it gives you a lot of information.

To start the project do a main.tf

Follow the instructions below, remembering that this test was done in the AWS cloud. But it is very similar to using other cloud providers.

It can be very simple, but I will explain step by step:

Provider : AWS, GCP, Azure and etc….

region: us-east-1(N.Virginia), sa-east-1(Brazil South)and more….

When you need to create any object be: s3, ec2, sqs it is necessary to place a resource.

AMI (Amazon Image) = ami-02354e95b39ca8dec

Type: terraform init — initialize Terraform deploy

terraform plan — plan your code

terraform apply — apply deploy using Terraform

EC2 Deployed

Terraform destroy — destroy environment

Sources:

AMI https://aws.amazon.com/amazon-linux-ami/?nc1=h_ls

Terraform Documentation Provider https://www.terraform.io/docs/providers/index.html

--

--