Skip to content

MissionCriticalCloud/terraform-cosmic-loadbalancer

Repository files navigation

terraform-cosmic-loadbalancer

Terraform module to create and manage a Cosmic load balancer.

This module will create a public IP address and configure it as a load balancer in the specified network. It will also create a network ACL for the public IP and add the public ports and allowed CIDRs as ingress ACL rules, ensuring all configured load balancer rules have a corresponding allow rule in the public IP's ACL.

Example

module "loadbalancer" {
  source     = "MissionCriticalCloud/loadbalancer/cosmic"
  name       = "MyApp"
  network_id = cosmic_network.default.id
  vpc_id     = cosmic_vpc.default.id

  services = {
    http = {
      allowed_cidrs = ["1.2.3.4/32"]
      member_ids    = cosmic_instance.default.*.id
      private_port  = 80
      public_port   = 80
      protocol      = "tcp"
    }

    https = {
      allowed_cidrs = ["1.2.3.4/32"]
      member_ids    = cosmic_instance.default.*.id
      private_port  = 443
      public_port   = 443
      protocol      = "tcp"
    }
  }
}

Requirements

Name Version
terraform >= 0.13

Providers

Name Version
cosmic n/a

Inputs

Name Description Type Default Required
name Name of load balancer and ACL string n/a yes
network_id VPC network ID string n/a yes
services n/a
map(object({
allowed_cidrs = list(string)
member_ids = list(string)
protocol = string
public_port = string
private_port = string
}))
n/a yes
vpc_id VPC ID string n/a yes

Outputs

Name Description
acl_id ACL ID
ip_address IP address