diff --git a/.tool-versions b/.tool-versions
index 6396e99..f1ecc83 100644
--- a/.tool-versions
+++ b/.tool-versions
@@ -2,3 +2,4 @@ terraform 1.5.7
terraform-docs 0.17.0
tflint 0.50.3
pre-commit 3.6.2
+python 3.12.1
diff --git a/README.md b/README.md
index a95ff6c..cd8177b 100644
--- a/README.md
+++ b/README.md
@@ -31,11 +31,14 @@ module "module_name" {
| Name | Version |
|------|---------|
-| [terraform](#requirement\_terraform) | >= 1.3.1 |
+| [terraform](#requirement\_terraform) | >= 1.5.7 |
+| [digitalocean](#requirement\_digitalocean) | >= 2.34.1 |
## Providers
-No providers.
+| Name | Version |
+|------|---------|
+| [digitalocean](#provider\_digitalocean) | >= 2.34.1 |
## Modules
@@ -43,15 +46,31 @@ No modules.
## Resources
-No resources.
+| Name | Type |
+|------|------|
+| [digitalocean_loadbalancer.main](https://registry.terraform.io/providers/digitalocean/digitalocean/latest/docs/resources/loadbalancer) | resource |
## Inputs
-No inputs.
+| Name | Description | Type | Default | Required |
+|------|-------------|------|---------|:--------:|
+| [droplet\_ids](#input\_droplet\_ids) | A list of the IDs of each droplet to be attached to the Load Balancer. | `list(string)` | `[]` | no |
+| [droplet\_tag](#input\_droplet\_tag) | The name of a Droplet tag corresponding to Droplets to be assigned to the Load Balancer. | `string` | `null` | no |
+| [firewall](#input\_firewall) | List of objects that represent the configuration of each healthcheck. | `list(any)` | `[]` | no |
+| [forwarding\_rule](#input\_forwarding\_rule) | List of objects for forwarding\_rule. | `list(any)` | `[]` | no |
+| [name](#input\_name) | The Load Balancer name | `string` | n/a | yes |
+| [region](#input\_region) | The region to start in | `string` | n/a | yes |
+| [size](#input\_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 |
+| [size\_unit](#input\_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 |
+| [vpc\_uuid](#input\_vpc\_uuid) | The ID of the VPC where the load balancer will be located. | `string` | `""` | no |
## Outputs
-No outputs.
+| Name | Description |
+|------|-------------|
+| [id](#output\_id) | The ID of the Load Balancer. |
+| [ip](#output\_ip) | The ip of the Load Balancer. |
+| [urn](#output\_urn) | The urn for the Load Balancer. |
## Examples of usage
diff --git a/examples/example_of_use/main.tf b/examples/example_of_use/main.tf
index 9eda987..37ff1cf 100644
--- a/examples/example_of_use/main.tf
+++ b/examples/example_of_use/main.tf
@@ -1,4 +1,38 @@
-module "module_name" {
- source = "../../"
+provider "digitalocean" {
+ token = var.do_token
+}
+
+module "terraform_module_digitalocean_vpc" {
+ source = "github.com/opsd-io/terraform-module-digitalocean-vpc"
+ vpc_name = "your-vpc"
+ region = "nyc1"
+ description = "VPC added by terraform module"
+}
+
+
+module "digitalocean_droplet" {
+ source = "github.com/opsd-io/terraform-module-digitalocean-droplet?ref=MB_droplet_creation"
+ image = "ubuntu-20-04-x64"
+ name = "web-1"
+ region = "nyc1"
+ size = "s-1vcpu-1gb"
+ vpc_uuid = [module.terraform_module_digitalocean_vpc.id]
+}
+
+module "digitalocean_loadbalancer" {
+ source = "github.com/opsd-io/terraform-module-digitalocean-load-balancer?ref=load_balancer_module"
+ name = "loadbalancer-1"
+ region = "nyc1"
+ droplet_ids = [module.digitalocean_droplet.id]
+ vpc_uuid = [module.digitalocean_vpc.id]
+
+ forwarding_rule = [
+ {
+ entry_port = 80
+ entry_protocol = "http"
+ target_port = 80
+ target_protocol = "http"
+ }
+ ]
}
diff --git a/examples/example_of_use/variables.tf b/examples/example_of_use/variables.tf
new file mode 100644
index 0000000..6bec71f
--- /dev/null
+++ b/examples/example_of_use/variables.tf
@@ -0,0 +1,10 @@
+variable "do_token" {
+ description = "Token to digitalOcean API"
+ type = string
+}
+
+variable "droplet_ids" {
+ description = "A list of the IDs of each droplet to be attached to the Load Balancer."
+ type = list(string)
+ default = []
+}
diff --git a/examples/example_of_use/versions.tf b/examples/example_of_use/versions.tf
index b7d3369..1c9de3c 100644
--- a/examples/example_of_use/versions.tf
+++ b/examples/example_of_use/versions.tf
@@ -1,13 +1,9 @@
terraform {
- required_version = ">= 1.3.1"
+ required_version = ">= 1.5.7"
required_providers {
- # github = {
- # source = "integrations/github"
- # version = ">= 5.3.0"
- # }
- # azurerm = {
- # source = "hashicorp/azurerm"
- # version = ">= 3.22.0"
- # }
+ digitalocean = {
+ source = "digitalocean/digitalocean"
+ version = ">= 2.34.1"
+ }
}
}
diff --git a/main.tf b/main.tf
index 1c6a2e5..4995f61 100644
--- a/main.tf
+++ b/main.tf
@@ -1 +1,27 @@
-# Terraform code goes here
+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_rule
+ content {
+ entry_port = forwarding_rule.value.entry_port
+ entry_protocol = forwarding_rule.value.entry_protocol
+ target_port = forwarding_rule.value.target_port
+ target_protocol = forwarding_rule.value.target_protocol
+ }
+ }
+
+ dynamic "firewall" {
+ for_each = var.firewall
+ content {
+ deny = lookup(firewall.value, "deny", null)
+ allow = lookup(firewall.value, "allow", null)
+ }
+ }
+}
diff --git a/outputs.tf b/outputs.tf
index 47cec5f..4cc37b5 100644
--- a/outputs.tf
+++ b/outputs.tf
@@ -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
+}
diff --git a/variables.tf b/variables.tf
index a27d76b..cf952d4 100644
--- a/variables.tf
+++ b/variables.tf
@@ -1,12 +1,51 @@
-# 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 = ""
+}
+
+variable "forwarding_rule" {
+ 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 "firewall" {
+ description = "List of objects that represent the configuration of each healthcheck."
+ type = list(any)
+ default = []
+}
diff --git a/versions.tf b/versions.tf
index b7d3369..1c9de3c 100644
--- a/versions.tf
+++ b/versions.tf
@@ -1,13 +1,9 @@
terraform {
- required_version = ">= 1.3.1"
+ required_version = ">= 1.5.7"
required_providers {
- # github = {
- # source = "integrations/github"
- # version = ">= 5.3.0"
- # }
- # azurerm = {
- # source = "hashicorp/azurerm"
- # version = ">= 3.22.0"
- # }
+ digitalocean = {
+ source = "digitalocean/digitalocean"
+ version = ">= 2.34.1"
+ }
}
}