initial AWS terraform (#180)

* initial AWS terraform
This commit is contained in:
3u13r 2022-09-27 14:02:56 +02:00 committed by GitHub
parent a6d201b761
commit 130c61ffcf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 612 additions and 0 deletions

View file

@ -0,0 +1,48 @@
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 4.0"
}
}
}
resource "aws_lb" "front_end" {
name = var.name
internal = false
load_balancer_type = "network"
subnets = [var.subnet]
tags = {
Name = "loadbalancer"
}
enable_cross_zone_load_balancing = true
}
resource "aws_lb_target_group" "front_end" {
name = var.name
port = var.port
protocol = "TCP"
vpc_id = var.vpc
health_check {
port = var.port
protocol = "TCP"
}
lifecycle {
create_before_destroy = true
}
}
resource "aws_lb_listener" "front_end" {
load_balancer_arn = aws_lb.front_end.arn
port = var.port
protocol = "TCP"
default_action {
type = "forward"
target_group_arn = aws_lb_target_group.front_end.arn
}
}

View file

@ -0,0 +1,3 @@
output "target_group_arn" {
value = aws_lb_target_group.front_end.arn
}

View file

@ -0,0 +1,19 @@
variable "name" {
type = string
description = "Name of the load balancer."
}
variable "port" {
type = string
description = "Port of the load balancer."
}
variable "vpc" {
type = string
description = "ID of the VPC."
}
variable "subnet" {
type = string
description = "ID of the subnets."
}