Basic Terraform to create an instance on AWS

This is basic implement infrastructure as code using terraform:

First, install terraform binary, this is like a command:

https://nciptandani.blogspot.com/2020/11/how-to-install-terraform-command-in.html


Second, because of using AWS so install AWS-CLI and then configure it with your credentials like using AWS IAM policy EC2-Full access, in this tutorial just only to create an instance.


Third, create a folder for the project


mkdir learn-terraform

cd learn-terraform

vim main.tf

  resource "aws_instance" "my-practice-www1" {

  ami = "ami-015a6758451df3cb9"

  instance_type = "t2.micro"

  }


The last, executing the terraform command.


Default AWS configuration will be called automatically by the terraform so just executing that code with the terraform command below:


terraform init


terraform plan

terraform apply


So yeah just one file main.tf with some code we can create an instance on AWS but of course with the default configuration.


More resources: https://learn.hashicorp.com/collections/terraform/aws-get-started


Komentar

Postingan populer dari blog ini

Pembahasan IT Network Systems Administration Module A DNS (Forward Zone, Reverse Zone, CNAME, MX, Split View)

Cara restart / stop windows service (services.msc) dengan bat / cmd

How to convert VMDK to OVA