syslog-server/terraform/ec2.tf

35 lines
979 B
HCL

resource "aws_instance" "this" {
ami = var.ami_id
instance_type = "t4g.small"
subnet_id = aws_subnet.public.id
private_ip = local.collector_private_ip
vpc_security_group_ids = [aws_security_group.this.id]
iam_instance_profile = aws_iam_instance_profile.this.name
associate_public_ip_address = true
user_data = local.user_data
user_data_replace_on_change = true
root_block_device {
volume_size = 20
volume_type = "gp3"
encrypted = true
}
metadata_options {
http_endpoint = "enabled"
http_tokens = "required"
}
tags = {
Name = "syslog-server"
}
}
locals {
user_data = templatefile("${path.module}/user_data.sh.tftpl", {
vector_yaml = templatefile("${path.module}/vector.yaml.tftpl", {
aws_region = var.aws_region
firehose_stream = aws_kinesis_firehose_delivery_stream.unifi.name
})
})
}