Skip to content

Commit

Permalink
Creating loadbalancer module (#185)
Browse files Browse the repository at this point in the history
* Creating loadbalancer module

* Upd version

* Changes loadbalancer

* Adding l4 and l7 conf

* Description
  • Loading branch information
jorge-cr-13 authored Feb 19, 2024
1 parent 3219b7f commit bcdcfa3
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 0 deletions.
25 changes: 25 additions & 0 deletions otc/loadbalancer/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
resource "opentelekomcloud_lb_loadbalancer_v3" "elb" {
name = "${var.name}-lb"
router_id = var.vpc_id
network_ids = [var.subnet_id]

availability_zones = var.availability_zones
l4_flavor = var.l4_flavor
l7_flavor = var.l7_flavor

public_ip {
id = opentelekomcloud_vpc_eip_v1.ingress_eip.id
}
}

resource "opentelekomcloud_vpc_eip_v1" "ingress_eip" {
bandwidth {
charge_mode = "traffic"
name = "${var.name}-ingress-bandwidth"
share_type = "PER"
size = var.bandwidth
}
publicip {
type = "5_bgp"
}
}
11 changes: 11 additions & 0 deletions otc/loadbalancer/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
output "elb_id" {
value = opentelekomcloud_lb_loadbalancer_v3.elb.id
}

output "elb_private_ip" {
value = opentelekomcloud_lb_loadbalancer_v3.elb.vip_address
}

output "elb_public_ip" {
value = opentelekomcloud_vpc_eip_v1.ingress_eip.publicip[0].ip_address
}
9 changes: 9 additions & 0 deletions otc/loadbalancer/terraform.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
terraform {
required_version = "v1.3.7"
required_providers {
opentelekomcloud = {
source = "opentelekomcloud/opentelekomcloud"
version = "1.36.1"
}
}
}
37 changes: 37 additions & 0 deletions otc/loadbalancer/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
variable "name" {
type = string
description = "Project name."
}

variable "bandwidth" {
type = number
default = 300
description = "The bandwidth size. The value ranges from 1 to 1000 Mbit/s."
}

variable "vpc_id" {
type = string
description = "VPC where the elastic load balancer will be created."
}

variable "subnet_id" {
type = string
description = "Subnets where the elastic load balancer will be created."
}

variable "availability_zones" {
type = list(string)
description = "Specifies the availability zones where the LoadBalancer will be located."
}

variable "l4_flavor" {
type = string
description = "The flavor for the L4(NLB) ELB, if not assigned and L7 also not assigned then both will be created with default values"
default = null
}

variable "l7_flavor" {
type = string
description = "The flavor for the L7(ALB) ELB, if not assigned and L4 also not assigned then both will be created with default values"
default = null
}

0 comments on commit bcdcfa3

Please sign in to comment.