Terraform module to build http/https redirects totally using GCP load balancer components.
This module is meant for use with Terraform 1.3+ and tested using Terraform 1.12. If you find incompatibilities using Terraform >=1.11, please open an issue.
module "http_redirects" {
source = "github.com/broadinstitute/terraform-google-redirect//modules/http_redirects"
default_destination_host = var.default_destination_host
default_destination_path = var.default_destination_path
default_redirect_response_code = var.default_redirect_response_code
hostnames = var.hostnames
name = var.name
project = google_project.default.project_id
redirects = var.redirects
ssl_policy = google_compute_ssl_policy.default.self_link
}
default_destination_host
: The domain/hostname where any non-matching requests should go.default_destination_path
: The path underdefault_destination_host
where any non-matching requests should go.hostnames
: A map of lists where each map is a certificate to be created, with the value being the list of hostnames that should be in the certificate.redirects
: A list of maps with any path-level redirects that should happen under the provided hostnames. This field can be left blank (i.e.[]
) which will effectively redirect all the provided hostnames to the default host and path. The fields within the map are:destination_host
: The host portion of the URL for the redirectdestination_path
: The path portion of the URL for the redirect`redirect_response_code
: The HTTP code that should be used when doing a redirect.source_paths
: The list of paths under the source hostnames that should trigger a redirect. __Note: If you want to redirect a path ending with a slash (/
) as well as one without a slash, you will need to make sure both paths are in the list.
Terraform Docs created by running the following from the root of the repository:
podman run --rm -u $(id -u) \
--volume "$(pwd):/terraform-docs" \
-w /terraform-docs \
quay.io/terraform-docs/terraform-docs:latest \
--output-file ../../docs/README.md \
--output-mode inject /terraform-docs/modules/http_redirects
Name | Version |
---|---|
terraform | >= 1.10 |
>= 6, < 7 |
Name | Version |
---|---|
>= 6, < 7 |
Name | Source | Version |
---|---|---|
certificates | ../certificates | n/a |
Name | Description | Type | Default | Required |
---|---|---|---|---|
default_destination_host | The default host to redirect to if no paths are matched. | string |
n/a | yes |
default_destination_path | The default path to redirect to if no paths are matched. | string |
n/a | yes |
hostnames | A map of certificates to create, with the value being the list of hostnames | map(list(string)) |
n/a | yes |
project | The GCP project ID | string |
n/a | yes |
redirects | The map of redirects to apply to the path under the hostname. | list(object({ |
n/a | yes |
default_redirect_response_code | The default response code to use for redirects. | string |
"MOVED_PERMANENTLY_DEFAULT" |
no |
name | The name to use for all resources created. | string |
null |
no |
ssl_policy | The SSL policy to use for the redirects. | string |
null |
no |
Name | Description |
---|---|
load_balancer_ip_address | IP address of the HTTP Cloud Load Balancer |