How to launch VPC with the help of Terraform

Опубликовано: 22 Август 2026
на канале: Pari Cloud Knowledge
109
10

Lecture 2 || Lab 1 on to install Terraform and launch EC2 instance automatically with the help of Terraform || Praveen Kumar || Hindi/English.
Link :    • Lecture 2 || Lab 1 on to install Terraform...  

Lecture 1 || Introduction about Terraform || Praveen Kumar || Industries requirement
Link :    • How to launch VPC with the help of Terrafo...  

Pari Cloud Knowledge - A YouTube channel for system administrator's/Linux/AWS/ and DevOps engineers. My aim is to spread knowledge on basics to industry level among Hindi and English people. Please like subscribe and share my videos to all.

#######################################################
data "aws_ami" "ubuntu" {
most_recent = true

filter {
name = "name"
values = ["ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-*"]
}

filter {
name = "virtualization-type"
values = ["hvm"]
}

owners = ["099720109477"] # Canonical
}

resource "aws_instance" "web" {
ami = data.aws_ami.ubuntu.id
instance_type = "t3.micro"

tags = {
Name = "HelloWorld"
}
}

######################################################
VPC LAB :


resource "aws_vpc" "my_vpc" {
cidr_block = "172.16.0.0/16"

tags = {
Name = "tf-example"
}
}

resource "aws_subnet" "my_subnet" {
vpc_id = aws_vpc.my_vpc.id
cidr_block = "172.16.10.0/24"
availability_zone = "us-west-2a"

tags = {
Name = "tf-example"
}
}

resource "aws_network_interface" "foo" {
subnet_id = aws_subnet.my_subnet.id
private_ips = ["172.16.10.100"]

tags = {
Name = "primary_network_interface"
}
}

resource "aws_instance" "foo" {
ami = "ami-005e54dee72cc1d00" # us-west-2
instance_type = "t2.micro"

network_interface {
network_interface_id = aws_network_interface.foo.id
device_index = 0
}

credit_specification {
cpu_credits = "unlimited"
}
}