From 0b1b1d2521e69dc15ced8641ccfe947118707091 Mon Sep 17 00:00:00 2001 From: Solomon Negusse Date: Fri, 8 Nov 2024 21:00:45 +0300 Subject: [PATCH 1/3] update dataset name; allow test datasets --- app/routes/titiler/umd_glad_dist_alerts.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/app/routes/titiler/umd_glad_dist_alerts.py b/app/routes/titiler/umd_glad_dist_alerts.py index 04d346e1..a84ac5ae 100644 --- a/app/routes/titiler/umd_glad_dist_alerts.py +++ b/app/routes/titiler/umd_glad_dist_alerts.py @@ -18,8 +18,7 @@ router = APIRouter() -# TODO: update to the actual dataset when ready -DATASET = "dan_test" +DATASET = "umd_glad_dist_alerts" today = date.today() @@ -30,8 +29,16 @@ tags=["Raster Tiles"], response_description="PNG Raster Tile", ) +@router.get( + "/{dataset}/{version}/titiler/{z}/{x}/{y}.png", # for testing datasets - hidden from docs. + response_class=Response, + tags=["Raster Tiles"], + response_description="PNG Raster Tile", + include_in_schema=False, +) async def glad_dist_alerts_raster_tile( *, + dataset: str = DATASET, version, xyz: Tuple[int, int, int] = Depends(raster_xyz), start_date: Optional[str] = Query( @@ -71,7 +78,7 @@ async def glad_dist_alerts_raster_tile( tile_x, tile_y, zoom = xyz bands = ["default", "intensity"] - folder: str = f"s3://{DATA_LAKE_BUCKET}/{DATASET}/{version}/raster/epsg-4326/cog" + folder: str = f"s3://{DATA_LAKE_BUCKET}/{dataset}/{version}/raster/epsg-4326/cog" with AlertsReader(input=folder) as reader: # NOTE: the bands in the output `image_data` array will be in the order of # the input `bands` list From 691bd241ab2ca54862ae6032b2983f8c9ed85b81 Mon Sep 17 00:00:00 2001 From: Solomon Negusse Date: Sun, 10 Nov 2024 15:45:07 +0300 Subject: [PATCH 2/3] add titiler endpoint to cloudfront --- .../modules/content_delivery_network/main.tf | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/terraform/modules/content_delivery_network/main.tf b/terraform/modules/content_delivery_network/main.tf index 9b45eca4..e86f8be0 100644 --- a/terraform/modules/content_delivery_network/main.tf +++ b/terraform/modules/content_delivery_network/main.tf @@ -455,6 +455,31 @@ resource "aws_cloudfront_distribution" "tiles" { } } + ordered_cache_behavior { + allowed_methods = local.methods + cached_methods = local.methods + target_origin_id = "dynamic" + compress = true + path_pattern = "*/titiler/*" + default_ttl = 86400 + max_ttl = 86400 + min_ttl = 0 + smooth_streaming = false + trusted_signers = [] + viewer_protocol_policy = "redirect-to-https" + + forwarded_values { + headers = local.headers + query_string = true + query_string_cache_keys = [] + + cookies { + forward = "none" + whitelisted_names = [] + } + } + } + # Default static vector tiles are stored on S3 # They won't change and can stay in cache for a year # We will set response headers for selected tile caches in S3 if required From 4a5326459ba5758d525931fb5999147b45514896 Mon Sep 17 00:00:00 2001 From: Solomon Negusse Date: Mon, 11 Nov 2024 13:34:23 +0300 Subject: [PATCH 3/3] add clarifying comment for the two titiler paths --- terraform/modules/content_delivery_network/main.tf | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/terraform/modules/content_delivery_network/main.tf b/terraform/modules/content_delivery_network/main.tf index e86f8be0..6d40e01d 100644 --- a/terraform/modules/content_delivery_network/main.tf +++ b/terraform/modules/content_delivery_network/main.tf @@ -423,7 +423,7 @@ resource "aws_cloudfront_distribution" "tiles" { } } - # send all Titiler requests to tile cache app + # send all generic Titiler requests to tile cache app ordered_cache_behavior { allowed_methods = local.methods cached_methods = local.methods @@ -455,6 +455,7 @@ resource "aws_cloudfront_distribution" "tiles" { } } +# pass requests for DIST alerts test datasets to tile cache app ordered_cache_behavior { allowed_methods = local.methods cached_methods = local.methods