Skip to content

Commit

Permalink
https_redirect
Browse files Browse the repository at this point in the history
  • Loading branch information
Sohan Yadav committed Oct 4, 2019
1 parent 14de74b commit fda8603
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,10 @@ This module has a few dependencies:




## Examples


**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).


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






## Inputs

| Name | Description | Type | Default | Required |
Expand All @@ -116,6 +121,7 @@ Here is an example of how you can use this module in your inventory structure:
| health_check_timeout | The amount of time to wait in seconds before failing a health check request. | number | `10` | no |
| health_check_unhealthy_threshold | The number of consecutive health check failures required before considering the target unhealthy. | number | `2` | no |
| http_enabled | A boolean flag to enable/disable HTTP listener. | bool | `true` | no |
| http_listener_type | The type of routing action. Valid values are forward, redirect, fixed-response, authenticate-cognito and authenticate-oidc. | string | `redirect` | no |
| http_port | The port on which the load balancer is listening. like 80 or 443. | number | `80` | no |
| https_enabled | A boolean flag to enable/disable HTTPS listener. | bool | `true` | no |
| https_port | The port on which the load balancer is listening. like 80 or 443. | number | - | yes |
Expand All @@ -135,6 +141,7 @@ Here is an example of how you can use this module in your inventory structure:
| log_bucket_name | S3 bucket (externally created) for storing load balancer access logs. Required if logging_enabled is true. | string | `` | no |
| name | Name (e.g. `app` or `cluster`). | string | `` | no |
| security_groups | A list of security group IDs to assign to the LB. Only valid for Load Balancers of type application. | list | `<list>` | no |
| status_code | The HTTP redirect code. The redirect is either permanent (HTTP_301) or temporary (HTTP_302). | string | `HTTP_301` | no |
| 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 |
| 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 |
| tags | Additional tags (e.g. map(`BusinessUnit`,`XYZ`). | map | `<map>` | no |
Expand All @@ -161,8 +168,8 @@ Here is an example of how you can use this module in your inventory structure:



## Testing

## Testing
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.

You need to run the following command in the testing folder:
Expand Down
7 changes: 6 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,12 @@ resource "aws_lb_listener" "http" {
protocol = "HTTP"
default_action {
target_group_arn = aws_lb_target_group.main.arn
type = var.listener_type
type = var.http_listener_type
redirect {
port = var.https_port
protocol = var.listener_protocol
status_code = var.status_code
}
}
}

Expand Down
12 changes: 12 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -273,4 +273,16 @@ variable "health_check_matcher" {
type = string
default = "200-399"
description = "The HTTP response codes to indicate a healthy check."
}

variable "http_listener_type" {
type = string
default = "redirect"
description = "The type of routing action. Valid values are forward, redirect, fixed-response, authenticate-cognito and authenticate-oidc."
}

variable "status_code" {
type = string
default = "HTTP_301"
description = " The HTTP redirect code. The redirect is either permanent (HTTP_301) or temporary (HTTP_302)."
}

0 comments on commit fda8603

Please sign in to comment.