generated from opsd-io/terraform-module-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1 create load balancer terraform module (#3)
* Load balancer module (#2) * initial commit * changed name * path change * repo * ip range * module name corr * corr * example change * some corrections * added firewal deny allow
- Loading branch information
Showing
12 changed files
with
208 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
12 changes: 1 addition & 11 deletions
12
examples/example_of_use/README.mkdn → examples/basic/README.mkdn
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
module "do_vpc" { | ||
source = "github.com/opsd-io/terraform-module-digitalocean-vpc" | ||
vpc_name = "your-vpc" | ||
region = "nyc1" | ||
ip_range = "192.168.0.0/24" | ||
description = "VPC added by terraform module" | ||
} | ||
|
||
|
||
module "digitalocean_droplet" { | ||
source = "github.com/opsd-io/terraform-module-digitalocean-droplet" | ||
image = "ubuntu-20-04-x64" | ||
name = "web-1" | ||
region = "nyc1" | ||
size = "s-1vcpu-1gb" | ||
vpc_uuid = module.do_vpc.id | ||
} | ||
|
||
module "digitalocean_loadbalancer" { | ||
source = "github.com/opsd-io/terraform-module-digitalocean-load-balancer" | ||
name = "loadbalancer-1" | ||
region = "nyc1" | ||
droplet_ids = [module.digitalocean_droplet.id] | ||
vpc_uuid = module.do_vpc.id | ||
|
||
forwarding_rule = [ | ||
{ | ||
entry_port = 80 | ||
entry_protocol = "http" | ||
|
||
target_port = 80 | ||
target_protocol = "http" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
terraform { | ||
required_version = ">= 1.5.7" | ||
|
||
required_providers { | ||
digitalocean = { | ||
source = "digitalocean/digitalocean" | ||
version = ">= 2.34.1" | ||
} | ||
} | ||
} | ||
|
||
provider "digitalocean" { | ||
token = var.do_token | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
variable "do_token" { | ||
description = "Token to digitalOcean API." | ||
type = string | ||
default = null | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,50 @@ | ||
# Terraform code goes here | ||
terraform { | ||
required_version = ">= 1.5.7" | ||
|
||
required_providers { | ||
digitalocean = { | ||
source = "digitalocean/digitalocean" | ||
version = ">= 2.34.1" | ||
} | ||
} | ||
} | ||
|
||
resource "digitalocean_loadbalancer" "main" { | ||
name = var.name | ||
region = var.region | ||
size = var.size | ||
size_unit = var.size_unit | ||
vpc_uuid = var.vpc_uuid | ||
droplet_ids = var.droplet_ids | ||
droplet_tag = var.droplet_tag | ||
|
||
dynamic "forwarding_rule" { | ||
for_each = var.forwarding_rules | ||
content { | ||
entry_port = forwarding_rules.value.entry_port | ||
entry_protocol = forwarding_rules.value.entry_protocol | ||
target_port = forwarding_rules.value.target_port | ||
target_protocol = forwarding_rules.value.target_protocol | ||
certificate_name = forwarding_rules.value.certificate_name | ||
tls_passthrough = forwarding_rule.value.tls_passthrough | ||
} | ||
} | ||
|
||
firewall { | ||
allow = var.firewall_allow | ||
deny = var.firewall_deny | ||
} | ||
|
||
dynamic "healthcheck" { | ||
for_each = var.healthcheck | ||
content { | ||
port = healthcheck.value.port | ||
protocol = healthcheck.value.protocol | ||
path = healthcheck.value.path | ||
check_interval_seconds = healthcheck.value.check_interval_seconds | ||
response_timeout_seconds = healthcheck.value.response_timeout_seconds | ||
unhealthy_threshold = healthcheck.value.unhealthy_threshold | ||
healthy_threshold = healthcheck.value.healthy_threshold | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,14 @@ | ||
# output "variable" { | ||
# description = "output variable description" | ||
# value = variable.main.name | ||
# } | ||
output "id" { | ||
description = "The ID of the Load Balancer." | ||
value = digitalocean_loadbalancer.main.id | ||
} | ||
|
||
output "ip" { | ||
description = "The ip of the Load Balancer." | ||
value = digitalocean_loadbalancer.main.ip | ||
} | ||
|
||
output "urn" { | ||
description = "The urn for the Load Balancer." | ||
value = digitalocean_loadbalancer.main.urn | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,63 @@ | ||
# variable "variable_name" { | ||
# description = "variable description" | ||
# type = number | ||
# default = 1 | ||
# } | ||
|
||
# variable "variable_password" { | ||
# description = "variable description" | ||
# type = string | ||
# sensitive = true | ||
# default = "abc" | ||
# } | ||
variable "name" { | ||
description = "The Load Balancer name." | ||
type = string | ||
} | ||
|
||
variable "region" { | ||
description = "The region to start in." | ||
type = string | ||
} | ||
|
||
variable "size" { | ||
description = "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." | ||
type = string | ||
default = "lb-small" | ||
} | ||
|
||
variable "size_unit" { | ||
description = "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." | ||
type = number | ||
default = 1 | ||
} | ||
|
||
variable "vpc_uuid" { | ||
description = "The ID of the VPC where the load balancer will be located." | ||
type = string | ||
default = null | ||
} | ||
|
||
variable "forwarding_rules" { | ||
description = "List of objects for forwarding_rule." | ||
type = list(any) | ||
default = [] | ||
} | ||
|
||
variable "droplet_ids" { | ||
description = "A list of the IDs of each droplet to be attached to the Load Balancer." | ||
type = list(string) | ||
default = [] | ||
} | ||
|
||
variable "droplet_tag" { | ||
description = "The name of a Droplet tag corresponding to Droplets to be assigned to the Load Balancer." | ||
type = string | ||
default = null | ||
} | ||
|
||
variable "healthcheck" { | ||
type = list(any) | ||
default = [] | ||
description = "List of objects that represent the configuration of each healthcheck." | ||
} | ||
|
||
variable "firewall_allow" { | ||
description = "List of objects that represent the configuration of firewall allow variables." | ||
type = list(string) | ||
default = [] | ||
} | ||
|
||
variable "firewall_deny" { | ||
description = "List of objects that represent the configuration of firewall deny variables." | ||
type = list(string) | ||
default = [] | ||
} |
This file was deleted.
Oops, something went wrong.