diff --git a/docs/URL_FIX_DOCUMENTATION.md b/docs/URL_FIX_DOCUMENTATION.md index e441b37..d6eeb0f 100644 --- a/docs/URL_FIX_DOCUMENTATION.md +++ b/docs/URL_FIX_DOCUMENTATION.md @@ -43,9 +43,12 @@ La función se asoció con todos los cache behaviors de CloudFront para asegurar ## Archivos Modificados 1. **mkdocs.yml**: Agregada configuración `use_directory_urls: true` -2. **terraform/cloudfront.tf**: +2. **terraform/cloudfront.tf**: - Agregada CloudFront Function `url_rewrite` - Asociada la función con todos los cache behaviors +3. **terraform/cloudfront-staging.tf**: + - Aplicada la misma CloudFront Function a staging + - Asociada la función con todos los cache behaviors de staging ## Despliegue @@ -67,11 +70,19 @@ Para aplicar estos cambios: ## Verificación Después del despliegue, verificar que funcionen: + +### Producción - ✅ `https://pythoncdmx.org/meetups/` - ✅ `https://pythoncdmx.org/meetups/index.html` - ✅ `https://pythoncdmx.org/about/` - ✅ `https://pythoncdmx.org/about/index.html` +### Staging +- ✅ `https://staging.pythoncdmx.org/meetups/` +- ✅ `https://staging.pythoncdmx.org/meetups/index.html` +- ✅ `https://staging.pythoncdmx.org/about/` +- ✅ `https://staging.pythoncdmx.org/about/index.html` + ## Notas Técnicas - La CloudFront Function se ejecuta en el edge, por lo que tiene latencia mínima diff --git a/terraform/cloudfront-staging.tf b/terraform/cloudfront-staging.tf index 3504eb0..bbe7ba9 100644 --- a/terraform/cloudfront-staging.tf +++ b/terraform/cloudfront-staging.tf @@ -7,6 +7,9 @@ resource "aws_cloudfront_origin_access_control" "website_staging" { signing_protocol = "sigv4" } +# CloudFront Function for staging (reuse the same function as production) +# Note: CloudFront Functions are global, so we can reference the same function + # CloudFront distribution for staging resource "aws_cloudfront_distribution" "website_staging" { enabled = true @@ -42,6 +45,12 @@ resource "aws_cloudfront_distribution" "website_staging" { default_ttl = 300 # 5 minutes - shorter cache for staging max_ttl = 3600 # 1 hour - shorter cache for staging compress = true + + # Associate CloudFront Function for URL rewriting (same as production) + function_association { + event_type = "viewer-request" + function_arn = aws_cloudfront_function.url_rewrite.arn + } } # Cache behavior for static assets (CSS) - shorter cache for staging @@ -63,6 +72,12 @@ resource "aws_cloudfront_distribution" "website_staging" { default_ttl = 1800 # 30 minutes max_ttl = 7200 # 2 hours compress = true + + # Associate CloudFront Function for URL rewriting + function_association { + event_type = "viewer-request" + function_arn = aws_cloudfront_function.url_rewrite.arn + } } # Cache behavior for static assets (JS) - shorter cache for staging @@ -84,6 +99,12 @@ resource "aws_cloudfront_distribution" "website_staging" { default_ttl = 1800 # 30 minutes max_ttl = 7200 # 2 hours compress = true + + # Associate CloudFront Function for URL rewriting + function_association { + event_type = "viewer-request" + function_arn = aws_cloudfront_function.url_rewrite.arn + } } # Cache behavior for images - shorter cache for staging @@ -105,6 +126,12 @@ resource "aws_cloudfront_distribution" "website_staging" { default_ttl = 3600 # 1 hour max_ttl = 86400 # 24 hours compress = true + + # Associate CloudFront Function for URL rewriting + function_association { + event_type = "viewer-request" + function_arn = aws_cloudfront_function.url_rewrite.arn + } } # Custom error responses for SPA-like behavior