diff --git a/README.md b/README.md index 4e69414..32cb806 100644 --- a/README.md +++ b/README.md @@ -9,19 +9,28 @@ This module is used for redirecting all requests from one or more `from` domains // Must have Route53 zones for each domain to redirect from. Subdomains that get // redirected can use the same zones as parent domains that get redirected. resource "aws_route53_zone" "from_domain_1" { - name = "my-old-domain.com" + provider = aws.route53 + name = "my-old-domain.com" } resource "aws_route53_zone" "from_domain_2" { - name = "my-other-old-domain.com" + provider = aws.route53 + name = "my-other-old-domain.com" } module "domain_redirect" { source = "Invicton-Labs/domain-redirect/aws" - // The provider must always be in us-east-1, since that's where CloudFront gets deployed providers = { - aws = aws.us-east-1 + // This is the provider used for the CloudFront distribution and ACM certificate for the "to" domain. + // It must always be in us-east-1, since that's where CloudFront gets deployed. + aws.cloudfront = aws.us-east-1 + + // This is the provider that will be used for creating DNS records in the hosted zone(s) for the "from" domains. + // It can be in any region and any AWS account, as long as it's in the same account/region as the hosted zones. + // It creates Alias records that point to the CloudFront distribution, and creates validation records + // for the ACM certificate that is used by CloudFront. + aws.route53 = aws.route53 } // This is a map of domain names to Route53 zone IDs. The Route53 diff --git a/acm.tf b/acm.tf index 7facb94..1b1eff3 100644 --- a/acm.tf +++ b/acm.tf @@ -6,7 +6,7 @@ module "cloudfront_cert" { source = "Invicton-Labs/validated-acm-certificate/aws" version = "~> 0.1.3" providers = { - aws.hosted_zones = aws.route53_to + aws.hosted_zones = aws.route53 aws.certificate = aws.cloudfront } depends_on = [ diff --git a/route53.tf b/route53.tf index da59ff3..c4db919 100644 --- a/route53.tf +++ b/route53.tf @@ -1,6 +1,6 @@ // Create a Route53 record for each domain resource "aws_route53_record" "cloudfront" { - provider = aws.route53_from + provider = aws.route53 for_each = var.domains_from zone_id = each.value name = each.key diff --git a/versions.tf b/versions.tf index 30f8479..14cd287 100644 --- a/versions.tf +++ b/versions.tf @@ -4,7 +4,7 @@ terraform { aws = { source = "hashicorp/aws" version = "~> 4.8" - configuration_aliases = [aws.cloudfront, aws.route53_to, aws.route53_from] + configuration_aliases = [aws.cloudfront, aws.route53] } } }