Creating an EC2 instance using Terraform (AWS)

This article has not been completed yet. However, it may already contain helpful information and therefore it has been published at this stage.


1) Setting up a development environment

Obtaining via Chocolatey...

Administrative Shell (PowerShell):

choco install terraform -y -f

Add the path below

C:\ProgramData\chocolatey\lib\terraform\tools
terraform -v

.tf - Extension

main.tf

https://registry.terraform.io/browse/providers

terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
    }
  }
}

provider "aws" {
  profile = "default"
  region  = "eu-central-1"
}

resource "aws_instance" "app_server" {
  ami           = "ami-07df274a488ca9195"
  instance_type = "t2.micro"

  tags = {
    Name = "ExampleAppServerInstance"
  }
}
terraform init
terraform plan
terraform apply
terraform destroy

Sources: