i am at day 98.
i am facing issue, i ec2 instance is taking so much time even lab time is over still it creating ec2 instance . is there any issue in my code i am sharing with this
main.tf
resource “aws_vpc” “devops_priv_vpc” {
cidr_block = var.KKE_VPC_CIDR
tags = {
Name = “devops-priv-vpc”
}
}
resource “aws_subnet” “devops_priv_subnet” {
vpc_id = aws_vpc.devops_priv_vpc.id
cidr_block = var.KKE_SUBNET_CIDR
map_public_ip_on_launch = false
tags = {
Name = "devops-priv-subnet"
}
}
resource “aws_security_group” “devops_priv_sg”{
name = “devops_priv_sg”
vpc_id = aws_vpc.devops_priv_vpc.id
description = “Security group for devops_priv_sg”
tags = {
Name = "devops_priv_sg"
}
}
resource “aws_vpc_security_group_ingress_rule” “allow_http” {
security_group_id = aws_security_group.devops_priv_sg.id
from_port = 80
to_port = 80
ip_protocol = “tcp”
cidr_ipv4 = var.KKE_VPC_CIDR
}
resource “aws_vpc_security_group_ingress_rule” “allow_ssh” {
security_group_id = aws_security_group.devops_priv_sg.id
from_port = 22
to_port = 22
ip_protocol = “tcp”
cidr_ipv4 = var.KKE_VPC_CIDR
}
resource “aws_vpc_security_group_egress_rule” “allow_all_outbound” {
security_group_id = aws_security_group.devops_priv_sg.id
from_port = 0
to_port = 0
ip_protocol = “-1”
cidr_ipv4 = “0.0.0.0/0”
}
data “aws_ami” “amazon_linux” {
most_recent = true
owners = [“amazon”]
filter {
name = "name"
values = ["amzn2-ami-hvm-*-x86_64-ebs"]
}
}
resource “aws_instance” “devops_priv_ec2” {
ami = data.aws_ami.amazon_linux.id
instance_type = “t2.micro”
subnet_id = aws_subnet.devops_priv_subnet.id
vpc_security_group_ids = [aws_security_group.devops_priv_sg.id]
tags = {
Name = "devops-priv-ec2"
}
}
variables.tf
variable “KKE_VPC_CIDR” {
type = string
description = “this is vpc CIDR range”
default= “10.0.0.0/16”
}
variable “KKE_SUBNET_CIDR” {
type = string
description = “this is vpc subnet range”
default = “10.0.1.0/24”
}
outputs.tf
output “KKE_vpc_name” {
value = aws_vpc.devops_priv_vpc.tags[“Name”]
description = “this is name of the vpc”
}
output “KKE_subnet_name” {
value = aws_subnet.devops_priv_subnet.tags[“Name”]
description = “this is name of subnet”
}
output “KKE_ec2_private” {
value = aws_instance.devops_priv_ec2.tags[“Name”]
description = “this is name of the ec2 instance”
}