Skip to content

Commit

Permalink
[DEV-1538] Reach Media Library CDN using custom domain (#766)
Browse files Browse the repository at this point in the history
  • Loading branch information
kin0992 authored Mar 21, 2024
1 parent 5d2e69c commit 6be6508
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/silly-forks-shake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"infrastructure": patch
---

Configure a CDN alias and add a DNS A record to ensure the DNS is accessible
2 changes: 2 additions & 0 deletions apps/infrastructure/src/cloudfront.tf
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ module "cloudfront_cms" {
minimum_protocol_version = "TLSv1.2_2021"
}

aliases = module.strapi_media_library_ssl_certificate.distinct_domain_names

default_cache_behavior = {
allowed_methods = ["GET", "HEAD", "OPTIONS", "PUT", "POST", "PATCH", "DELETE"]
cached_methods = ["GET", "HEAD", "OPTIONS"]
Expand Down
13 changes: 13 additions & 0 deletions apps/infrastructure/src/route53.tf
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,16 @@ module "active_campaign_dns_records" {
}
]
}

// This Route53 record will point at the Strapi Media Library CDN
resource "aws_route53_record" "strapi_media_library" {
zone_id = aws_route53_zone.dev_portal.zone_id
name = format("cdn.%s", var.dns_domain_name)
type = "A"

alias {
name = module.cloudfront_cms.cloudfront_distribution_domain_name
zone_id = module.cloudfront_cms.cloudfront_distribution_hosted_zone_id
evaluate_target_health = false
}
}

0 comments on commit 6be6508

Please sign in to comment.