From 7be7b0990015f401cd18d68c59f95a6447dce09c Mon Sep 17 00:00:00 2001 From: kuannie1 Date: Tue, 19 Nov 2024 13:33:48 -0800 Subject: [PATCH] fix: add an optional redirect bucket variable for the redirect module --- aws-cloudfront-domain-redirect/main.tf | 3 ++- aws-cloudfront-domain-redirect/variables.tf | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/aws-cloudfront-domain-redirect/main.tf b/aws-cloudfront-domain-redirect/main.tf index f6b74a8c..124ec4f0 100644 --- a/aws-cloudfront-domain-redirect/main.tf +++ b/aws-cloudfront-domain-redirect/main.tf @@ -9,7 +9,8 @@ locals { } resource "aws_s3_bucket" "redirect_bucket" { - bucket = "redirect-${var.source_domain}-to-${var.target_domain}" + bucket = (var.redirect_bucket_name == null) : "redirect-${var.source_domain}-to-${var.target_domain}" ? var.redirect_bucket_name + website { redirect_all_requests_to = "https://${var.target_domain}" } diff --git a/aws-cloudfront-domain-redirect/variables.tf b/aws-cloudfront-domain-redirect/variables.tf index 9b299a1b..a7ed6266 100755 --- a/aws-cloudfront-domain-redirect/variables.tf +++ b/aws-cloudfront-domain-redirect/variables.tf @@ -38,3 +38,9 @@ variable "lambda_cloudwatch_log_retention_in_days" { description = "Retention policy (in days) for Lambda function's logs in Cloudwatch" default = null } + +variable "redirect_bucket_name" { + type = string + description = "Unique name for the redirect bucket (provide if possible)." + default = null +} \ No newline at end of file