Giter Club home page Giter Club logo

terraform-do-modules / terraform-digitalocean-load-balancer Goto Github PK

View Code? Open in Web Editor NEW
8.0 2.0 0.0 47 KB

Terraform module to create Load-balancer resource . DigitalOcean Load Balancers ensure that the requests your application receives are only distributed to Droplets that have passed health checks.

Home Page: https://docs.digitalocean.com/tutorials/load-balancers/

License: Apache License 2.0

Makefile 0.57% HCL 95.34% Shell 4.09%
clouddrove devops digitalocean digitalocean-container-registry digitalocean-terraform-module hackoctoberfest iac-terraform terraform terraform-module

terraform-digitalocean-load-balancer's Introduction

Terraform DigitalOcean Load Balancer

Provides a DigitalOcean Load Balancer resource that allows you to manage Load between droplets.

Terraform Licence


We eat, drink, sleep and most importantly love DevOps. We are working towards strategies for standardizing architecture while ensuring security for the infrastructure. We are strong believer of the philosophy Bigger problems are always solved by breaking them into smaller manageable problems. Resonating with microservices architecture, it is considered best-practice to run database, cluster, storage in smaller connected yet manageable pieces within the infrastructure.

This module is basically combination of Terraform open source and includes automatation tests and examples. It also helps to create and improve your infrastructure with minimalistic code instead of maintaining the whole infrastructure code yourself.

We have fifty plus terraform modules. A few of them are comepleted and are available for open source usage while a few others are in progress.

Prerequisites

This module has a few dependencies:

Examples

IMPORTANT: Since the master branch used in source varies based on new modifications, we suggest that you use the release versions here.

Here are examples of how you can use this module in your inventory structure:

basic example

    module "load-balancer" {
    source             = "terraform-do-modules/load-balancer/digitalocean"
    version            = "1.0.0"
    name               = local.name
    environment        = local.environment
    region             = local.region
    vpc_uuid           = module.vpc.id
    droplet_ids        = module.droplet.id

    ######
    enabled_redirect_http_to_https = false
    forwarding_rule = [
      {
        entry_port     = 80
        entry_protocol = "http"
        target_port     = 80
        target_protocol = "http"
      },
      {
        entry_port     = 443
        entry_protocol = "https"
        target_port      = 80
        target_protocol  = "http"
        certificate_name = "demo"
      }
    ]
  }

complete example

    module "load-balancer" {
    source                   = "terraform-do-modules/load-balancer/digitalocean"
    version                  = "1.0.0"
    name                     = local.name
    environment              = local.environment
    region                   = local.region
    vpc_uuid                 = module.vpc.id
    droplet_ids              = module.droplet.id

    ######
    enabled_redirect_http_to_https = false
    forwarding_rule = [
      {
        entry_port     = 80
        entry_protocol = "http"
        target_port     = 80
        target_protocol = "http"
      },
      {
        entry_port     = 443
        entry_protocol = "https"
        target_port      = 80
        target_protocol  = "http"
        certificate_name = "demo"
      }
    ]

    healthcheck = [
      {
        port     = 80
        protocol = "http"
        check_interval_seconds   = 10
        response_timeout_seconds = 5
        unhealthy_threshold      = 3
        healthy_threshold        = 5
      }
    ]
    sticky_sessions = [
      {
        type               = "cookies"
        cookie_name        = "lb-cookie"
        cookie_ttl_seconds = 300
      }
    ]

    firewall = [
      {
        deny  = ["cidr:0.0.0.0/0"]
        allow = ["cidr:143.244.136.144/32"]
      }
    ]
  }

Inputs

Name Description Type Default Required
algorithm The load balancing algorithm used to determine which backend Droplet will be selected by a client. It must be either round_robin or least_connections. The default value is round_robin. string "round_robin" no
disable_lets_encrypt_dns_records A boolean value indicating whether to disable automatic DNS record creation for Let's Encrypt certificates that are added to the load balancer. Default value is false. bool false no
droplet_ids A list of the IDs of each droplet to be attached to the Load Balancer. list(string) [] no
droplet_tag The name of a Droplet tag corresponding to Droplets to be assigned to the Load Balancer. string null no
enable_backend_keepalive A boolean value indicating whether HTTP keepalive connections are maintained to target Droplets. Default value is false. bool false no
enable_proxy_protocol A boolean value indicating whether PROXY Protocol should be used to pass information from connecting client requests to the backend service. Default value is false. bool false no
enabled Whether to create the resources. Set to false to prevent the module from creating any resources. bool true no
enabled_redirect_http_to_https A boolean value indicating whether HTTP requests to the Load Balancer on port 80 will be redirected to HTTPS on port 443. Default value is false. bool false no
environment Environment (e.g. prod, dev, staging). string "" no
firewall List of objects that represent the configuration of each healthcheck. list(any) [] no
forwarding_rule List of objects that represent the configuration of each forwarding_rule. list(any) [] no
healthcheck List of objects that represent the configuration of each healthcheck. list(any) [] no
http_idle_timeout_seconds Specifies the idle timeout for HTTPS connections on the load balancer in seconds. number null no
label_order Label order, e.g. name,application. list(any)
[
"name",
"environment"
]
no
lb_size The size of the Load Balancer. It must be either lb-small, lb-medium, or lb-large. Defaults to lb-small. Only one of size or size_unit may be provided. string "lb-small" no
managedby ManagedBy, eg 'terraform-do-modules' or '[email protected]' string "terraform-do-modules" no
name Name (e.g. app or cluster). string "" no
project_id The ID of the project that the load balancer is associated with. If no ID is provided at creation, the load balancer associates with the user's default project. string null no
region The region to create VPC, like london-1 , bangalore-1 ,newyork-3 toronto-1. string "blr-1" no
size_unit The size of the Load Balancer. It must be in the range (1, 100). Defaults to 1. Only one of size or size_unit may be provided. number 1 no
sticky_sessions List of objects that represent the configuration of each healthcheck. list(any) [] no
vpc_uuid The ID of the VPC where the load balancer will be located. string "" no

Outputs

Name Description
id The ID of the Load Balancer.
ip The ip of the Load Balancer.
urn The uniform resource name for the Load Balancer.

Testing

In this module testing is performed with terratest and it creates a small piece of infrastructure, matches the output like ARN, ID and Tags name etc and destroy infrastructure in your AWS account. This testing is written in GO, so you need a GO environment in your system.

You need to run the following command in the testing folder:

  go test -run Test

Feedback

If you come accross a bug or have any feedback, please log it in our issue tracker, or feel free to drop us an email at [email protected].

If you have found it worth your time, go ahead and give us a ★ on our GitHub!

About us

At CloudDrove, we offer expert guidance, implementation support and services to help organisations accelerate their journey to the cloud. Our services include docker and container orchestration, cloud migration and adoption, infrastructure automation, application modernisation and remediation, and performance engineering.

We are The Cloud Experts!


We ❤️ Open Source and you can check out our other modules to get help with your new Cloud ideas.

terraform-digitalocean-load-balancer's People

Contributors

anmolnagpal avatar clouddrove-ci avatar cloudlovely avatar d4kverma avatar dependabot[bot] avatar themaheshyadav avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.