diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6685b96..656323b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,10 +1,10 @@ repos: - repo: git://github.com/antonbabenko/pre-commit-terraform - rev: v1.19.0 + rev: v1.31.0 hooks: - id: terraform_fmt - id: terraform_docs - repo: git://github.com/pre-commit/pre-commit-hooks - rev: v2.3.0 + rev: v3.1.0 hooks: - id: check-merge-conflict diff --git a/README.md b/README.md index d02e082..44ea26d 100644 --- a/README.md +++ b/README.md @@ -79,26 +79,34 @@ module "elb_http" { * Valid SSL certificate has to be specified as `ssl_id_certificate` argument for secure listener. Use [terraform-aws-acm module](https://github.com/terraform-aws-modules/terraform-aws-acm) to create one. See [ELB example](https://github.com/terraform-aws-modules/terraform-aws-elb/blob/master/examples/complete/main.tf) for details. +## Requirements + +No requirements. + +## Providers + +No provider. + ## Inputs | Name | Description | Type | Default | Required | -|------|-------------|:----:|:-----:|:-----:| -| access\_logs | An access logs block | map(string) | `{}` | no | -| connection\_draining | Boolean to enable connection draining | bool | `"false"` | no | -| connection\_draining\_timeout | The time in seconds to allow for connections to drain | number | `"300"` | no | -| create\_elb | Create the elb or not | bool | `"true"` | no | -| cross\_zone\_load\_balancing | Enable cross-zone load balancing | bool | `"true"` | no | -| health\_check | A health check block | map(string) | n/a | yes | -| idle\_timeout | The time in seconds that the connection is allowed to be idle | number | `"60"` | no | -| instances | List of instances ID to place in the ELB pool | list(string) | `[]` | no | -| internal | If true, ELB will be an internal ELB | string | n/a | yes | -| listener | A list of listener blocks | list(map(string)) | n/a | yes | -| name | The name of the ELB | string | `"null"` | no | -| name\_prefix | The prefix name of the ELB | string | `"null"` | no | -| number\_of\_instances | Number of instances to attach to ELB | number | `"0"` | no | -| security\_groups | A list of security group IDs to assign to the ELB | list(string) | n/a | yes | -| subnets | A list of subnet IDs to attach to the ELB | list(string) | n/a | yes | -| tags | A mapping of tags to assign to the resource | map(string) | `{}` | no | +|------|-------------|------|---------|:--------:| +| access\_logs | An access logs block | `map(string)` | `{}` | no | +| connection\_draining | Boolean to enable connection draining | `bool` | `false` | no | +| connection\_draining\_timeout | The time in seconds to allow for connections to drain | `number` | `300` | no | +| create\_elb | Create the elb or not | `bool` | `true` | no | +| cross\_zone\_load\_balancing | Enable cross-zone load balancing | `bool` | `true` | no | +| health\_check | A health check block | `map(string)` | n/a | yes | +| idle\_timeout | The time in seconds that the connection is allowed to be idle | `number` | `60` | no | +| instances | List of instances ID to place in the ELB pool | `list(string)` | `[]` | no | +| internal | If true, ELB will be an internal ELB | `string` | n/a | yes | +| listener | A list of listener blocks | `list(map(string))` | n/a | yes | +| name | The name of the ELB | `string` | `null` | no | +| name\_prefix | The prefix name of the ELB | `string` | `null` | no | +| number\_of\_instances | Number of instances to attach to ELB | `number` | `0` | no | +| security\_groups | A list of security group IDs to assign to the ELB | `list(string)` | n/a | yes | +| subnets | A list of subnet IDs to attach to the ELB | `list(string)` | n/a | yes | +| tags | A mapping of tags to assign to the resource | `map(string)` | `{}` | no | ## Outputs diff --git a/examples/complete/README.md b/examples/complete/README.md index 676f9f6..99c65e8 100644 --- a/examples/complete/README.md +++ b/examples/complete/README.md @@ -19,11 +19,22 @@ $ terraform apply Note that this example may create resources which cost money. Run `terraform destroy` when you don't need these resources. +## Requirements + +No requirements. + +## Providers + +| Name | Version | +|------|---------| +| aws | n/a | +| random | n/a | + ## Inputs | Name | Description | Type | Default | Required | -|------|-------------|:----:|:-----:|:-----:| -| number\_of\_instances | Number of instances to create and attach to ELB | string | `"1"` | no | +|------|-------------|------|---------|:--------:| +| number\_of\_instances | Number of instances to create and attach to ELB | `number` | `1` | no | ## Outputs @@ -31,7 +42,7 @@ Note that this example may create resources which cost money. Run `terraform des |------|-------------| | this\_elb\_dns\_name | The DNS name of the ELB | | this\_elb\_id | The name of the ELB | -| this\_elb\_instances | The list of instances in the ELB (if may be outdated, because instances are attached using elb_attachment resource) | +| this\_elb\_instances | The list of instances in the ELB (if may be outdated, because instances are attached using elb\_attachment resource) | | this\_elb\_name | The name of the ELB | | this\_elb\_source\_security\_group\_id | The ID of the security group that you can use as part of your inbound rules for your load balancer's back-end application instances | | this\_elb\_zone\_id | The canonical hosted zone ID of the ELB (to be used in a Route 53 Alias record) | diff --git a/main.tf b/main.tf index 1a2ef50..3c8d88f 100644 --- a/main.tf +++ b/main.tf @@ -4,6 +4,8 @@ module "elb" { source = "./modules/elb" + create_elb = var.create_elb + name = var.name name_prefix = var.name_prefix @@ -20,8 +22,6 @@ module "elb" { access_logs = var.access_logs health_check = var.health_check - create_elb = var.create_elb - tags = merge( var.tags, { @@ -36,10 +36,10 @@ module "elb" { module "elb_attachment" { source = "./modules/elb_attachment" + create_attachment = var.create_elb + number_of_instances = var.number_of_instances elb = module.elb.this_elb_id instances = var.instances - - create_attachment = var.create_elb } diff --git a/modules/elb/README.md b/modules/elb/README.md index 393ccbc..d70a2d9 100644 --- a/modules/elb/README.md +++ b/modules/elb/README.md @@ -1,24 +1,34 @@ # aws_elb +## Requirements + +No requirements. + +## Providers + +| Name | Version | +|------|---------| +| aws | n/a | + ## Inputs | Name | Description | Type | Default | Required | -|------|-------------|:----:|:-----:|:-----:| -| access\_logs | An access logs block | map(string) | `{}` | no | -| connection\_draining | Boolean to enable connection draining | bool | `"false"` | no | -| connection\_draining\_timeout | The time in seconds to allow for connections to drain | number | `"300"` | no | -| create\_elb | Create the elb or not | bool | `"true"` | no | -| cross\_zone\_load\_balancing | Enable cross-zone load balancing | bool | `"true"` | no | -| health\_check | A health check block | map(string) | n/a | yes | -| idle\_timeout | The time in seconds that the connection is allowed to be idle | number | `"60"` | no | -| internal | If true, ELB will be an internal ELB | bool | n/a | yes | -| listener | A list of listener blocks | list(map(string)) | n/a | yes | -| name | The name of the ELB | string | `"null"` | no | -| name\_prefix | The prefix name of the ELB | string | `"null"` | no | -| security\_groups | A list of security group IDs to assign to the ELB | list(string) | n/a | yes | -| subnets | A list of subnet IDs to attach to the ELB | list(string) | n/a | yes | -| tags | A mapping of tags to assign to the resource | map(string) | `{}` | no | +|------|-------------|------|---------|:--------:| +| access\_logs | An access logs block | `map(string)` | `{}` | no | +| connection\_draining | Boolean to enable connection draining | `bool` | `false` | no | +| connection\_draining\_timeout | The time in seconds to allow for connections to drain | `number` | `300` | no | +| create\_elb | Create the elb or not | `bool` | `true` | no | +| cross\_zone\_load\_balancing | Enable cross-zone load balancing | `bool` | `true` | no | +| health\_check | A health check block | `map(string)` | n/a | yes | +| idle\_timeout | The time in seconds that the connection is allowed to be idle | `number` | `60` | no | +| internal | If true, ELB will be an internal ELB | `bool` | n/a | yes | +| listener | A list of listener blocks | `list(map(string))` | n/a | yes | +| name | The name of the ELB | `string` | `null` | no | +| name\_prefix | The prefix name of the ELB | `string` | `null` | no | +| security\_groups | A list of security group IDs to assign to the ELB | `list(string)` | n/a | yes | +| subnets | A list of subnet IDs to attach to the ELB | `list(string)` | n/a | yes | +| tags | A mapping of tags to assign to the resource | `map(string)` | `{}` | no | ## Outputs diff --git a/modules/elb/main.tf b/modules/elb/main.tf index da2e8ba..e2bad80 100644 --- a/modules/elb/main.tf +++ b/modules/elb/main.tf @@ -1,4 +1,6 @@ resource "aws_elb" "this" { + count = var.create_elb ? 1 : 0 + name = var.name name_prefix = var.name_prefix @@ -46,6 +48,4 @@ resource "aws_elb" "this" { "Name" = format("%s", var.name) }, ) - - count = var.create_elb ? 1 : 0 } diff --git a/modules/elb/variables.tf b/modules/elb/variables.tf index 32b8418..a5481e6 100644 --- a/modules/elb/variables.tf +++ b/modules/elb/variables.tf @@ -1,3 +1,9 @@ +variable "create_elb" { + description = "Create the elb or not" + type = bool + default = true +} + variable "name" { description = "The name of the ELB" type = string @@ -70,9 +76,3 @@ variable "health_check" { description = "A health check block" type = map(string) } - -variable "create_elb" { - description = "Create the elb or not" - type = bool - default = true -} \ No newline at end of file diff --git a/modules/elb_attachment/README.md b/modules/elb_attachment/README.md index 909b2f8..36bbca4 100644 --- a/modules/elb_attachment/README.md +++ b/modules/elb_attachment/README.md @@ -1,13 +1,27 @@ # aws_elb_attachment +## Requirements + +No requirements. + +## Providers + +| Name | Version | +|------|---------| +| aws | n/a | + ## Inputs | Name | Description | Type | Default | Required | -|------|-------------|:----:|:-----:|:-----:| -| create\_attachment | Create the elb attachment or not | bool | `"true"` | no | -| elb | The name of the ELB | string | n/a | yes | -| instances | List of instances ID to place in the ELB pool | list(string) | n/a | yes | -| number\_of\_instances | Number of instances ID to place in the ELB pool | number | n/a | yes | +|------|-------------|------|---------|:--------:| +| create\_attachment | Create the elb attachment or not | `bool` | `true` | no | +| elb | The name of the ELB | `string` | n/a | yes | +| instances | List of instances ID to place in the ELB pool | `list(string)` | n/a | yes | +| number\_of\_instances | Number of instances ID to place in the ELB pool | `number` | n/a | yes | + +## Outputs + +No output. diff --git a/modules/elb_attachment/variables.tf b/modules/elb_attachment/variables.tf index 2d2fbe0..5547436 100644 --- a/modules/elb_attachment/variables.tf +++ b/modules/elb_attachment/variables.tf @@ -1,3 +1,9 @@ +variable "create_attachment" { + description = "Create the elb attachment or not" + type = bool + default = true +} + variable "number_of_instances" { description = "Number of instances ID to place in the ELB pool" type = number @@ -12,9 +18,3 @@ variable "instances" { description = "List of instances ID to place in the ELB pool" type = list(string) } - -variable "create_attachment" { - description = "Create the elb attachment or not" - type = bool - default = true -}