Install Terraform on Debian - you can follow the official documentation too:
sudo apt-get update && sudo apt-get install -y gnupg software-properties-common curl
curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add -
sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main"
sudo apt-get update && sudo apt-get install terraform
Authenticate to AWSsudo pip install awscli
Configure it:
aws configure
and enter saved Access Key ID and Secret Access Keyterraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 3.0"
}
}
}
provider "aws" {
region = "us-east-1"
}
resource "aws_instance" "example" {
ami = "ami-011899242bb902164" # Ubuntu 20.04 LTS
instance_type = "t3.nano"
}
Initialize the backend:
terraform init
Plan. See the changes to be applied as output:
terraform plan
Apply the changes:
terraform apply
you can now go the the AWS console to see the new-created instance details.terraform destroy