Yet another serverless lambda redirect. This one accepts a list of domain names and redirects them to a URL. For example:
module "redirect" {
source = "../lambda-redirect"
domain_mapping = {
"test.example.com": "https://example.com/test",
"mail.example.com": "https://mailprovider.com",
}
aws_acm_certificate = aws_acm_certificate.dev
http_redirect_code = 302
}
This redirect will append the path to redirected URLs. A user visiting test.example.com/path
will be redirected to https://example.com/test/path
. Note that the / in the URL will be appended to the mapped URL, which works well for top level domains but may cause issues trying to redirect to a specific document.
Name | Version |
---|---|
terraform | >= 0.12.26 |
aws | >= 3.15 |
Name | Version |
---|---|
archive | n/a |
aws | >= 3.15 |
No modules.
Name | Type |
---|---|
aws_api_gateway_base_path_mapping.mapping | resource |
aws_api_gateway_deployment.redirect | resource |
aws_api_gateway_domain_name.domain | resource |
aws_api_gateway_integration.redirect | resource |
aws_api_gateway_integration.redirect_root | resource |
aws_api_gateway_method.redirect | resource |
aws_api_gateway_method.redirect_root | resource |
aws_api_gateway_resource.redirect | resource |
aws_api_gateway_rest_api.redirect | resource |
aws_cloudwatch_log_group.redirect_lambda | resource |
aws_iam_policy.lambda_policy | resource |
aws_iam_role.lambda_execution_role | resource |
aws_iam_role_policy_attachment.lambda_execution_role | resource |
aws_lambda_function.redirect_lambda | resource |
aws_lambda_permission.redirect | resource |
archive_file.redirect_lambda | data source |
aws_iam_policy_document.lambda_assume_role | data source |
aws_iam_policy_document.lambda_policy | data source |
Name | Description | Type | Default | Required |
---|---|---|---|---|
aws_acm_certificate | ACM certificate to use with the source domains (must be in us-east-1!) | object({ |
n/a | yes |
domain_mapping | A key/value map of source domains -> target redirects. For example: domain_mapping: {"test.example.com": "https://example.com/test"} | map(string) |
n/a | yes |
http_redirect_code | Which HTTP redirect code to use (301 or 302) | string |
"301" |
no |
Name | Description |
---|---|
redirect_cloudfront_domains | n/a |