Skip to content

Ibotta/terraform-module-route53-domain-redirect

 
 

Repository files navigation

Route53 Domain Redirect

Diagram

This Terraform module works together with AWS Route53, S3, ACM and CloudFront to create permanent redirect of a domain to a target URL.

Both www and apex A records are created and pointed to a CloudFront distribution. The distribution accepts HTTP and HTTPS connections (free autorenewing ACM certificate is used for HTTPS). The origin for CloudFront distribution is a S3 hosted website with redirect-all rule. This solution is cheap and maintenance free.

Requirements: DNS Zone in Route53

To Deploy

Please review our Contributing docs for the review and release process.

Requirements

No requirements.

Providers

Name Version
aws n/a
random n/a

Modules

No modules.

Resources

Name Type
aws_acm_certificate.cert resource
aws_acm_certificate_validation.validation resource
aws_cloudfront_distribution.redirect resource
aws_route53_record.cert_validation resource
aws_route53_record.redirect resource
aws_route53_record.redirect-www resource
aws_s3_bucket.redirect_bucket resource
aws_s3_bucket_acl.redirect_bucket resource
aws_s3_bucket_ownership_controls.redirect_bucket resource
aws_s3_bucket_public_access_block.redirect_bucket resource
aws_s3_bucket_versioning.redirect_bucket resource
aws_s3_bucket_website_configuration.redirect_bucket resource
random_string.hash resource
aws_caller_identity.current data source
aws_region.current data source
aws_route53_zone.zone data source

Inputs

Name Description Type Default Required
tags n/a map(string) n/a yes
zone Route53 zone name string n/a yes
allow_overwrite Allow route53 to overwrite the current rule bool false no
remove_trailing_slash Remove trailing slash automatically added by S3 to the target URL. Conflicts with target_url. map(string) {} no
source_subdomain FQDN of subdomain that we want to redirect from. string "" no
target_url URL to redirect to string null no

Outputs

No outputs.

Changelog

1.2.8

  • Add variable remove_trailing_slash to allow removing trailing slash automatically added by S3 to the target URL.

1.2.7

  • specify minimum SSL protocol as TLSv1.2_2021

1.2.6

  • ignore web_acl_id in Cloudfront
  • add github action for formatting terraform and docs

1.2.5

  • Move s3 website configuration to it's own resource aws_s3_bucket_website_configuration.
  • Block S3 public access and set bucket ACL to private.
  • Add tags to aws_cloudfront_distribution.

1.2.4

  • Add aws_s3_bucket_versioning, and tag s3 buckets per org guidelines.

About

Terraform module for permanent domain redirect using AWS Route53

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • HCL 60.7%
  • Shell 39.3%