58 lines
1.9 KiB
HCL
58 lines
1.9 KiB
HCL
# ──────────────────────────────────────────────
|
|
# Security Group
|
|
# ──────────────────────────────────────────────
|
|
resource "aws_security_group" "langfuse" {
|
|
name = var.sg_name
|
|
description = "Allow defined ports for Langfuse"
|
|
vpc_id = var.vpc_id
|
|
|
|
dynamic "ingress" {
|
|
for_each = var.allowed_ports
|
|
content {
|
|
from_port = ingress.value
|
|
to_port = ingress.value
|
|
protocol = "tcp"
|
|
cidr_blocks = ["3.14.44.224/32"]
|
|
}
|
|
}
|
|
|
|
egress {
|
|
from_port = 0
|
|
to_port = 0
|
|
protocol = "-1"
|
|
cidr_blocks = ["0.0.0.0/0"]
|
|
}
|
|
|
|
tags = merge(var.tags, {
|
|
Name = var.sg_name
|
|
})
|
|
}
|
|
|
|
# ──────────────────────────────────────────────
|
|
# EC2 Instance
|
|
# ──────────────────────────────────────────────
|
|
resource "aws_instance" "langfuse" {
|
|
ami = data.aws_ami.ubuntu.id
|
|
instance_type = var.instance_type
|
|
subnet_id = var.subnet_id
|
|
vpc_security_group_ids = [aws_security_group.langfuse.id]
|
|
associate_public_ip_address = true
|
|
key_name = var.key_name != "" ? var.key_name : null
|
|
|
|
user_data = templatefile("${path.module}/user_data.sh.tftpl", {
|
|
langfuse_repo_url = var.langfuse_repo_url
|
|
langfuse_web_port = var.langfuse_web_port
|
|
ebs_device_name = var.ebs_device_name
|
|
})
|
|
|
|
root_block_device {
|
|
volume_size = var.root_volume_size
|
|
volume_type = var.root_volume_type
|
|
delete_on_termination = true
|
|
}
|
|
|
|
tags = merge(var.tags, {
|
|
Name = var.instance_name
|
|
})
|
|
}
|