Skip to content

Commit fda8603

Browse files
author
Sohan Yadav
committed
https_redirect
1 parent 14de74b commit fda8603

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,10 @@ This module has a few dependencies:
6161

6262

6363

64+
6465
## Examples
6566

67+
6668
**IMPORTANT:** Since the `master` branch used in `source` varies based on new modifications, we suggest that you use the release versions [here](https://github.com/clouddrove/terraform-aws-alb/releases).
6769

6870

@@ -93,6 +95,9 @@ Here is an example of how you can use this module in your inventory structure:
9395

9496

9597

98+
99+
100+
96101
## Inputs
97102

98103
| Name | Description | Type | Default | Required |
@@ -116,6 +121,7 @@ Here is an example of how you can use this module in your inventory structure:
116121
| health_check_timeout | The amount of time to wait in seconds before failing a health check request. | number | `10` | no |
117122
| health_check_unhealthy_threshold | The number of consecutive health check failures required before considering the target unhealthy. | number | `2` | no |
118123
| http_enabled | A boolean flag to enable/disable HTTP listener. | bool | `true` | no |
124+
| http_listener_type | The type of routing action. Valid values are forward, redirect, fixed-response, authenticate-cognito and authenticate-oidc. | string | `redirect` | no |
119125
| http_port | The port on which the load balancer is listening. like 80 or 443. | number | `80` | no |
120126
| https_enabled | A boolean flag to enable/disable HTTPS listener. | bool | `true` | no |
121127
| https_port | The port on which the load balancer is listening. like 80 or 443. | number | - | yes |
@@ -135,6 +141,7 @@ Here is an example of how you can use this module in your inventory structure:
135141
| log_bucket_name | S3 bucket (externally created) for storing load balancer access logs. Required if logging_enabled is true. | string | `` | no |
136142
| name | Name (e.g. `app` or `cluster`). | string | `` | no |
137143
| security_groups | A list of security group IDs to assign to the LB. Only valid for Load Balancers of type application. | list | `<list>` | no |
144+
| status_code | The HTTP redirect code. The redirect is either permanent (HTTP_301) or temporary (HTTP_302). | string | `HTTP_301` | no |
138145
| subnet_id | The id of the subnet of which to attach to the load balancer. You can specify only one subnet per Availability Zone. | string | `` | no |
139146
| subnets | A list of subnet IDs to attach to the LB. Subnets cannot be updated for Load Balancers of type network. Changing this value will for load balancers of type network will force a recreation of the resource. | list | `<list>` | no |
140147
| tags | Additional tags (e.g. map(`BusinessUnit`,`XYZ`). | map | `<map>` | no |
@@ -161,8 +168,8 @@ Here is an example of how you can use this module in your inventory structure:
161168

162169

163170

164-
## Testing
165171

172+
## Testing
166173
In this module testing is performed with [terratest](https://github.com/gruntwork-io/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](https://golang.org/doc/install) in your system.
167174

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

main.tf

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,12 @@ resource "aws_lb_listener" "http" {
6868
protocol = "HTTP"
6969
default_action {
7070
target_group_arn = aws_lb_target_group.main.arn
71-
type = var.listener_type
71+
type = var.http_listener_type
72+
redirect {
73+
port = var.https_port
74+
protocol = var.listener_protocol
75+
status_code = var.status_code
76+
}
7277
}
7378
}
7479

variables.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,4 +273,16 @@ variable "health_check_matcher" {
273273
type = string
274274
default = "200-399"
275275
description = "The HTTP response codes to indicate a healthy check."
276+
}
277+
278+
variable "http_listener_type" {
279+
type = string
280+
default = "redirect"
281+
description = "The type of routing action. Valid values are forward, redirect, fixed-response, authenticate-cognito and authenticate-oidc."
282+
}
283+
284+
variable "status_code" {
285+
type = string
286+
default = "HTTP_301"
287+
description = " The HTTP redirect code. The redirect is either permanent (HTTP_301) or temporary (HTTP_302)."
276288
}

0 commit comments

Comments
 (0)