Skip to content

Commit

Permalink
fix(DMVP-3212): Backwards compatibility for ingress module
Browse files Browse the repository at this point in the history
  • Loading branch information
viktoryathegreat committed Dec 21, 2023
1 parent 46070dd commit 60199df
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 10 deletions.
3 changes: 2 additions & 1 deletion modules/ingress/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,15 @@ spec:

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_additional_hostnames"></a> [additional\_hostnames](#input\_additional\_hostnames) | Additional hosts besides the main one: for example, if hostname is dasmeta.com, an additional hostname can be *.dasmeta.com | `list(string)` | `[]` | no |
| <a name="input_alarms"></a> [alarms](#input\_alarms) | Alarms for ALB | <pre>object({<br> enabled = optional(bool, true)<br> sns_topic = string<br> custom_values = optional(any, {})<br> })</pre> | n/a | yes |
| <a name="input_backend_protocol"></a> [backend\_protocol](#input\_backend\_protocol) | Specifies the protocol used when route traffic to pods. | `string` | `"HTTP"` | no |
| <a name="input_certificate_arn"></a> [certificate\_arn](#input\_certificate\_arn) | Specifies the ARN of one or more certificate managed by AWS Certificate Manager. If the alb.ingress.kubernetes.io/certificate-arn annotation is not specified, the controller will attempt to add certificates to listeners that require it by matching available certs from ACM with the host field in each listener's ingress rule. | `string` | `""` | no |
| <a name="input_default_backend"></a> [default\_backend](#input\_default\_backend) | n/a | <pre>object({<br> service_name = string<br> service_port = string<br> })</pre> | <pre>{<br> "service_name": null,<br> "service_port": null<br>}</pre> | no |
| <a name="input_enable_send_alb_logs_to_cloudwatch"></a> [enable\_send\_alb\_logs\_to\_cloudwatch](#input\_enable\_send\_alb\_logs\_to\_cloudwatch) | Send ALB logs to Cloudwatch | `bool` | `false` | no |
| <a name="input_healthcheck_path"></a> [healthcheck\_path](#input\_healthcheck\_path) | Specifies the HTTP path when performing health check on targets. | `string` | `"/"` | no |
| <a name="input_healthcheck_success_codes"></a> [healthcheck\_success\_codes](#input\_healthcheck\_success\_codes) | Specifies the HTTP status code that should be expected when doing health checks against the specified health check path. | `string` | `"200-399"` | no |
| <a name="input_hostnames"></a> [hostnames](#input\_hostnames) | Host is the fully qualified domain name of a network host. | `list(string)` | `null` | no |
| <a name="input_hostname"></a> [hostname](#input\_hostname) | Host is the fully qualified domain name of a network host. | `string` | `null` | no |
| <a name="input_load_balancer_attributes"></a> [load\_balancer\_attributes](#input\_load\_balancer\_attributes) | Specifies Load Balancer Attributes that should be applied to the ALB. | `string` | `""` | no |
| <a name="input_name"></a> [name](#input\_name) | Name of the Ingress, must be unique. | `string` | n/a | yes |
| <a name="input_namespace"></a> [namespace](#input\_namespace) | K8s namespace where the Ingress will be created. | `string` | `"default"` | no |
Expand Down
2 changes: 1 addition & 1 deletion modules/ingress/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ resource "kubernetes_ingress_v1" "this_v1" {
}
}
dynamic "rule" {
for_each = var.hostnames
for_each = var.additional_hostnames != [] ? concat([var.hostname], var.additional_hostnames) : [var.hostname]
content {
host = rule.value # Here, each hostname is assigned individually.

Expand Down
2 changes: 1 addition & 1 deletion modules/ingress/tests/basic/1-example.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module "ingress" {
source = "../.."

name = "dev"
hostnames = ["test.dasmeta.com"]
hostname = "test.dasmeta.com"
scheme = "internal"
namespace = "default"

Expand Down
2 changes: 1 addition & 1 deletion modules/ingress/tests/custom_alarms/1-example.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module "ingress" {
source = "../.."

name = "dev"
hostnames = ["test.dasmeta.com"]
hostname = "test.dasmeta.com"
scheme = "internal"
namespace = "default"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module "ingress" {
source = "../.."

name = "dev"
hostnames = ["test.dasmeta.com"]
hostname = "test.dasmeta.com"
scheme = "internal"
namespace = "default"

Expand Down
5 changes: 3 additions & 2 deletions modules/ingress/tests/multiple-domains/1-example.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ data "aws_acm_certificate" "issued" {
module "this" {
source = "../.."

name = "test"
hostnames = ["test.dasmeta.com", "*.test.dasmeta.com"]
name = "test"
hostname = "test.dasmeta.com"
additional_hostnames = ["*.test.dasmeta.com"]

certificate_arn = data.aws_acm_certificate.issued.arn
healthcheck_path = "/health"
Expand Down
2 changes: 1 addition & 1 deletion modules/ingress/tests/multiple-domains/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | ~> 4.0 |
| <a name="provider_aws"></a> [aws](#provider\_aws) | 4.67.0 |

## Modules

Expand Down
10 changes: 8 additions & 2 deletions modules/ingress/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,18 @@ variable "name" {
description = "Name of the Ingress, must be unique."
}

variable "hostnames" {
type = list(string)
variable "hostname" {
type = string
default = null
description = "Host is the fully qualified domain name of a network host."
}

variable "additional_hostnames" {
type = list(string)
default = []
description = "Additional hosts besides the main one: for example, if hostname is dasmeta.com, an additional hostname can be *.dasmeta.com"
}

variable "scheme" {
type = string
default = "internet-facing"
Expand Down

0 comments on commit 60199df

Please sign in to comment.