module "route53" {
  source = "../modules/route53"

  providers = {
    aws = aws.aws
  }

  zone_name = local.domain

  records = {
    root = {
      name = local.domain
      type = "A"
      alias = {
        name    = module.cloudfront["root"].distribution_domain_name
        zone_id = module.cloudfront["root"].distribution_hosted_zone_id
      }
    },
    www = {
      name = "www.${local.domain}"
      type = "A"
      alias = {
        name    = module.cloudfront["redirect"].distribution_domain_name
        zone_id = module.cloudfront["redirect"].distribution_hosted_zone_id
      }
    }
  }
}
