tf-aws-demo/modules/bastion_host/main.tf

44 lines
904 B
Terraform
Raw Permalink Normal View History

2022-08-24 14:14:42 +02:00
resource "aws_security_group" "this" {
name = "${var.PROJECT_NAME}-bastion-host-sg"
2022-08-24 14:14:42 +02:00
vpc_id = var.VPC_ID
ingress {
description = "SSH"
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_network_interface" "this" {
subnet_id = var.SUBNET_ID
2022-08-24 14:14:42 +02:00
security_groups = [aws_security_group.this.id]
tags = {
Name = "${var.PROJECT_NAME}-bastion-host-nic"
2022-08-24 14:14:42 +02:00
}
}
resource "aws_instance" "this" {
ami = var.EC2_AMI
instance_type = var.EC2_TYPE
key_name = var.EC2_KEY_NAME
2022-08-24 14:14:42 +02:00
network_interface {
network_interface_id = aws_network_interface.this.id
device_index = 0
}
tags = {
Name = "${var.PROJECT_NAME}-bastion-host"
2022-08-24 14:14:42 +02:00
}
}