Create an EC2 instance by terraform code
-Create an ubuntu ec2 machine wherein I will install terraform to perform the tasks in the cloud
- Download terraform
sudo su
wget -O- https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
sudo apt update && sudo apt install terraform
Lets now create a directory inside the machine where we will write terraform scripts
# mkdir terraform
# cd terraform
Documentation : https://registry.terraform.io/providers/hashicorp/aws/latest/docs
nano connection.tf
(remember that all the terraform scripts ends with .tf)
resource "aws_instance" "web" {
ami = data.aws_ami.ubuntu.id
instance_type = "t3.micro"
tags = {
Name = "HelloWorld"
}


















No comments:
Post a Comment