Main.tf file :
resource "aws_instance" "Web_siva" {
ami = "ami-0d13e3e640877b0b9"
subnet_id = "subnet-073f3aa87892560bb"
security_groups = ["${aws_security_group.ssh-security-group.id}","${aws_security_group.http-security-group.id}"]
associate_public_ip_address = true
instance_type = "t3.micro"
tags = {
Name = "Web_Siva"
}
}
terraform aws create security group
resource "aws_security_group" "ssh-security-group" {
name = "SSH Security Group"
description = "Enable SSH access on Port 22"
vpc_id = "vpc-0cf9861452054b3fc"
ingress {
description = "SSH Access"
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
}
resource "aws_security_group" "http-security-group" {
name = "HTTP Security Group"
description = "Enable HTTP access on Port 22"
vpc_id = "vpc-0cf9861452054b3fc"
ingress {
description = "HTTP Access"
from_port = 80
to_port = 80
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
}
=================================================================
Top comments (0)