From 00e49a9aef1ad5acd096fe982833515ce6d3cd5b Mon Sep 17 00:00:00 2001 From: Zack Pollard Date: Sun, 24 Nov 2024 23:24:53 +0000 Subject: [PATCH 1/4] feat: add oceania R2 bucket and test regions that could benefit --- .github/workflows/tiles-file.yml | 2 +- deployment/modules/cloudflare/tiles/r2.tf | 2 +- tiles/src/buckets.ts | 34 +++++++++++------------ tiles/src/index.ts | 1 + tiles/worker-configuration.d.ts | 17 ++++++------ tiles/wrangler.toml | 5 ++++ 6 files changed, 34 insertions(+), 27 deletions(-) diff --git a/.github/workflows/tiles-file.yml b/.github/workflows/tiles-file.yml index 117d29f..67c39bf 100644 --- a/.github/workflows/tiles-file.yml +++ b/.github/workflows/tiles-file.yml @@ -20,7 +20,7 @@ jobs: name: Deploy Tiles & Styles strategy: matrix: - bucket_region: [ "wnam", "enam", "weur", "eeur", "apac" ] + bucket_region: [ "wnam", "enam", "weur", "eeur", "apac", "oc" ] defaults: run: working-directory: 'map-styles' diff --git a/deployment/modules/cloudflare/tiles/r2.tf b/deployment/modules/cloudflare/tiles/r2.tf index d1070d2..79f9144 100644 --- a/deployment/modules/cloudflare/tiles/r2.tf +++ b/deployment/modules/cloudflare/tiles/r2.tf @@ -1,5 +1,5 @@ locals { - r2_regions = ["WNAM", "ENAM", "WEUR", "EEUR", "APAC"] + r2_regions = ["WNAM", "ENAM", "WEUR", "EEUR", "APAC", "OC"] } resource "cloudflare_r2_bucket" "tiles" { diff --git a/tiles/src/buckets.ts b/tiles/src/buckets.ts index 492d507..3dd58ea 100644 --- a/tiles/src/buckets.ts +++ b/tiles/src/buckets.ts @@ -1,9 +1,9 @@ -export type R2BucketRegion = 'apac' | 'eeur' | 'enam' | 'wnam' | 'weur'; +export type R2BucketRegion = 'apac' | 'eeur' | 'enam' | 'wnam' | 'weur' | 'oc'; export const preferredBuckets: { [key: string]: R2BucketRegion[] } = { ABQ: ['enam'], ADB: ['eeur'], - AKL: ['wnam'], + AKL: ['wnam', 'oc'], ALA: ['eeur'], ALG: ['eeur'], AMM: ['eeur'], @@ -13,19 +13,19 @@ export const preferredBuckets: { [key: string]: R2BucketRegion[] } = { ATH: ['eeur'], ATL: ['enam'], AUS: ['wnam'], - BKK: ['apac'], + BKK: ['apac', 'oc'], BNU: ['weur'], BOD: ['eeur'], BOG: ['wnam'], - BOM: ['apac'], + BOM: ['apac', 'oc'], BOS: ['enam'], BRU: ['weur'], BSB: ['wnam'], BUF: ['enam'], BUD: ['eeur'], - CBR: ['apac'], + CBR: ['apac', 'oc'], CDG: ['weur'], - CGK: ['apac'], + CGK: ['apac', 'oc'], CLT: ['enam'], CMB: ['apac'], COK: ['apac'], @@ -47,10 +47,10 @@ export const preferredBuckets: { [key: string]: R2BucketRegion[] } = { GYE: ['enam'], HAM: ['weur'], HFA: ['eeur'], - HKG: ['apac'], + HKG: ['apac', 'oc'], HYD: ['apac'], IAD: ['enam'], - ICN: ['apac'], + ICN: ['apac', 'oc'], IST: ['weur'], JAX: ['enam'], JNB: ['enam', 'eeur'], @@ -59,7 +59,7 @@ export const preferredBuckets: { [key: string]: R2BucketRegion[] } = { KHH: ['apac'], KIX: ['apac'], KTM: ['apac'], - KUL: ['apac'], + KUL: ['apac', 'oc'], LAS: ['wnam'], LAX: ['wnam'], LCA: ['eeur'], @@ -72,20 +72,20 @@ export const preferredBuckets: { [key: string]: R2BucketRegion[] } = { MAN: ['weur'], MBA: ['weur'], MCI: ['enam'], - MEL: ['wnam'], + MEL: ['wnam', 'oc'], MIA: ['enam'], - MNL: ['apac'], + MNL: ['apac', 'oc'], MRS: ['weur'], MSP: ['enam'], MUC: ['weur'], MXP: ['weur'], - NOU: ['wnam'], - NRT: ['apac'], + NOU: ['wnam', 'oc'], + NRT: ['apac', 'oc'], OKC: ['wnam'], ORD: ['enam'], OSL: ['weur'], OTP: ['eeur'], - PER: ['apac'], + PER: ['apac', 'oc'], PRG: ['weur'], PTY: ['enam'], RDU: ['enam'], @@ -93,17 +93,17 @@ export const preferredBuckets: { [key: string]: R2BucketRegion[] } = { RIX: ['eeur'], SCL: ['enam', 'weur'], SEA: ['wnam'], - SIN: ['apac'], + SIN: ['apac', 'oc'], SJC: ['wnam'], SMF: ['wnam'], SOF: ['eeur'], STL: ['enam'], STR: ['eeur'], - SYD: ['wnam'], + SYD: ['wnam', 'oc'], TBS: ['eeur'], TGU: ['enam'], TLV: ['eeur'], - TPE: ['apac'], + TPE: ['apac', 'oc'], UDI: ['enam', 'weur'], UIO: ['enam', 'weur'], VIE: ['eeur'], diff --git a/tiles/src/index.ts b/tiles/src/index.ts index e1833ec..1971bcc 100644 --- a/tiles/src/index.ts +++ b/tiles/src/index.ts @@ -163,6 +163,7 @@ async function handleRequest( enam: env.BUCKET_ENAM, wnam: env.BUCKET_WNAM, weur: env.BUCKET_WEUR, + oc: env.BUCKET_OC, }; const colo = request.cf?.colo || ''; const buckets: R2BucketRegion[] = preferredBuckets[colo] || ['weur', 'eeur', 'enam', 'wnam', 'apac']; diff --git a/tiles/worker-configuration.d.ts b/tiles/worker-configuration.d.ts index 9069787..f0f3ac4 100644 --- a/tiles/worker-configuration.d.ts +++ b/tiles/worker-configuration.d.ts @@ -2,12 +2,13 @@ // by running `wrangler types` interface Env { - KV: KVNamespace; - DEPLOYMENT_KEY: "20240812"; - ENVIRONMENT: "prod"; - BUCKET_WNAM: R2Bucket; - BUCKET_ENAM: R2Bucket; - BUCKET_WEUR: R2Bucket; - BUCKET_EEUR: R2Bucket; - BUCKET_APAC: R2Bucket; + KV: KVNamespace; + DEPLOYMENT_KEY: "20240812"; + ENVIRONMENT: "prod"; + BUCKET_WNAM: R2Bucket; + BUCKET_ENAM: R2Bucket; + BUCKET_WEUR: R2Bucket; + BUCKET_EEUR: R2Bucket; + BUCKET_APAC: R2Bucket; + BUCKET_OC: R2Bucket; } diff --git a/tiles/wrangler.toml b/tiles/wrangler.toml index 4fe3001..a2f8a6d 100644 --- a/tiles/wrangler.toml +++ b/tiles/wrangler.toml @@ -38,6 +38,11 @@ binding = "BUCKET_APAC" bucket_name = "tiles-apac" preview_bucket_name = "tiles-apac" +[[r2_buckets]] +binding = "BUCKET_OC" +bucket_name = "tiles-oc" +preview_bucket_name = "tiles-oc" + # Define environment variables for your Workers script [vars] DEPLOYMENT_KEY = "20240812" From a579a9896eb64b98f84dfdc4ca5aa8d24f583bfe Mon Sep 17 00:00:00 2001 From: Zack Pollard Date: Mon, 25 Nov 2024 13:20:39 +0000 Subject: [PATCH 2/4] chore: remove old and unused tiles bucket --- deployment/modules/cloudflare/tiles/r2.tf | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/deployment/modules/cloudflare/tiles/r2.tf b/deployment/modules/cloudflare/tiles/r2.tf index 79f9144..ac16f30 100644 --- a/deployment/modules/cloudflare/tiles/r2.tf +++ b/deployment/modules/cloudflare/tiles/r2.tf @@ -2,11 +2,6 @@ locals { r2_regions = ["WNAM", "ENAM", "WEUR", "EEUR", "APAC", "OC"] } -resource "cloudflare_r2_bucket" "tiles" { - account_id = var.cloudflare_account_id - name = "tiles" -} - resource "cloudflare_r2_bucket" "regional_tiles" { for_each = { for region in local.r2_regions : region => region } account_id = var.cloudflare_account_id @@ -14,11 +9,6 @@ resource "cloudflare_r2_bucket" "regional_tiles" { location = each.value } -import { - to = cloudflare_r2_bucket.tiles - id = "${var.cloudflare_account_id}/tiles" -} - output "r2_regional_buckets" { value = { for region, bucket in cloudflare_r2_bucket.regional_tiles : region => bucket.id } } From cb87ceb389b8b63778c84d2100529ce08908d822 Mon Sep 17 00:00:00 2001 From: Zack Pollard Date: Wed, 27 Nov 2024 12:02:12 +0000 Subject: [PATCH 3/4] chore: bump cloudflare tf provider to 4.47.0 --- .../tiles-worker/.terraform.lock.hcl | 47 +++++++------------ .../modules/cloudflare/tiles-worker/config.tf | 2 +- .../cloudflare/tiles/.terraform.lock.hcl | 47 +++++++------------ deployment/modules/cloudflare/tiles/config.tf | 2 +- 4 files changed, 36 insertions(+), 62 deletions(-) diff --git a/deployment/modules/cloudflare/tiles-worker/.terraform.lock.hcl b/deployment/modules/cloudflare/tiles-worker/.terraform.lock.hcl index 160c4f7..3ee579f 100644 --- a/deployment/modules/cloudflare/tiles-worker/.terraform.lock.hcl +++ b/deployment/modules/cloudflare/tiles-worker/.terraform.lock.hcl @@ -2,37 +2,24 @@ # Manual edits may be lost in future updates. provider "registry.opentofu.org/cloudflare/cloudflare" { - version = "4.46.0" - constraints = "4.46.0" + version = "4.47.0" + constraints = "4.47.0" hashes = [ - "h1:3U4N3bbMacXTAdyaEwT305kETMETh1jZmGApmN6gdyE=", - "h1:3fhZhGNgtS9ugcZ2CIH6kk8LzN6yPxqOdkDUZqkP3+w=", - "h1:JWluJxBRSr8GVUhWVv83xse9SmbpwCLctCDddMXUnVk=", - "h1:KDHwakGt+3iBKXaoALCCAolPaJgpEHbkh3BfjnpuqoM=", - "h1:QFFZshAvwr9L5TQmsNQC6/sDqokk5pjbP8Ae4BQqMLQ=", - "h1:Qdi+vXwzDNii7ytSaOQtnlqhjZ3ZlRoUkFoi6CD2COI=", - "h1:TPcJXcVb/+C91hUuu8CEn98QUoNgLtnHfd4sgAOV+5k=", - "h1:WDy5wiNroXaCnw+r8rJnCP+J1RVsm2Qu3AOZ/iV4lLo=", - "h1:hMuL+dwHj3JbePqYcDrn/ZQN9R0WzeJX0AIDJ02Iteo=", - "h1:hQKCaUEARzJKbFt1CePP06E/+CiHWe/H6lc1AwK7y6w=", - "h1:l4DQ3WXmSzR/GBel3m2CRKWtaziVjBoxvUgL63t1GK0=", - "h1:nN9uVSLyrb/DjfZl6rPtCq5j0TX+6WypzNDexdzCQ08=", - "h1:rAX7njl6lKT9XIKMk6pLjVi7u/42wafRolWWgMHMkI0=", - "h1:t2IQYNu8YNykqYlEB+TTX+XpUd5z2flwGw8km9UgbnQ=", - "zh:2ee426ef3389022db0026792fdc4f2980dcf2600e31adf5a31b4bddfa8d68343", - "zh:2f993edb23df55dc1c18150fa187d80aa7d87e6439698ee34b6a6aad23ac2dd7", - "zh:3d6601333975e55979b1b454e50ff9a482ce4e0269dd6c72a50202163a8f4463", - "zh:4e5f48dce22f7a6d618018d65d1d443bb718defa23f514d5c6385860541fbe79", - "zh:5ebf5aea960fc30de381ffd6db20876d249673cf938fe67f1dfb6b9caa1db418", - "zh:80ed3fb901141f53b4b56ddb7eea5f2e0c0830d501387539d2c2b8e0cc7e587a", + "h1:jRNDuRaXbNFMLQZ298HoXodPUqI+4VVl8xgsCKAg5Yg=", + "zh:1df6a36bad08e95518987a15584e535a1dad5fa0ee6e067c0c39d709a285f6b9", + "zh:20dce2a63f24f571f4d52d3217811d71e8d21f149f751d5972ec19200674638a", + "zh:6571aeeb61d4a27b4210a1979028119a1905e162b0c3845e7b549d6e0a08c36d", + "zh:87ec7ebe65c8884e174999c22970e2f28b0da4e0f65bdc92db051eb3dd649f78", "zh:890df766e9b839623b1f0437355032a3c006226a6c200cd911e15ee1a9014e9f", - "zh:9aeae8b3be4a577ced46987fd9159262c5b4c54a510f66592fbcdb40fef55b10", - "zh:a0479ef2d308c4a7894f1fe77467cd07e04c7b40d281088f4f204af1bdf94ac6", - "zh:a2bdc0c25130665af0b9559942b9813a1ba4889513e7185d4abc9c02e9bb99bd", - "zh:b10be9755fe80395ced6f0bbda38b8c8681714cf1eca1d895be239c75c2ffc2a", - "zh:ba3d55e722d9f48646574ce7c448f0084fe21fa884b5f8b6d6146a82a99c4baa", - "zh:ec1fd0ecaedc787a77d5342b51ae8dea8362a67f1e19123f6521a0e8e012d9e8", - "zh:ed49590e69faef14550179f965b4451b31415b8f6be6d33427ad48f65c76b6cf", - "zh:f4baa3a2dac719ad20dcfa525bc3f737ad95650b8d0de0c648dc9a87f993b2c3", + "zh:a20d1c0865a9443ada90ab7c83bd8605024452cf1e9f3b2ed2efcf06221b7835", + "zh:a5a5a91f658029ae3bb0414643ca09bd6a98a1980e197a9eb2ea4ba96a190d88", + "zh:b12623a85840821c465b87b1d65542f8f4a77079afef0ad2cc102a9f6eb4045c", + "zh:b83ac4f0b81aee32b3670f5870245172741bb86b153623da687d3c45ec9c1af9", + "zh:bb1ad4fcb949b12e5b40a21e65963ff64e20e72ab4c87a3ec91306b440a2cf35", + "zh:cb5a8bc24444a9d8f536b5acb7f6346f12c03e23539b183cb370f4876992360f", + "zh:ce6cc02ac4fc8cdf48a64254fdb0ea859b5b48e7fc08c7f1fcb8e9364ed32434", + "zh:e44643c86d38799991f5eb2378c00ca4738ec0f21dd64536dadffd71a337d778", + "zh:e5024d6792fcaa974b5f294399eea9b9c7d3d5d228423e71941994858a20c58f", + "zh:f9b18d0443487e30e0f3b83e311f17c85d184dc9f55b3f9b31332e815c41745a", ] } diff --git a/deployment/modules/cloudflare/tiles-worker/config.tf b/deployment/modules/cloudflare/tiles-worker/config.tf index e2043c8..e0201ee 100644 --- a/deployment/modules/cloudflare/tiles-worker/config.tf +++ b/deployment/modules/cloudflare/tiles-worker/config.tf @@ -5,7 +5,7 @@ terraform { required_providers { cloudflare = { source = "cloudflare/cloudflare" - version = "4.46.0" + version = "4.47.0" } } } diff --git a/deployment/modules/cloudflare/tiles/.terraform.lock.hcl b/deployment/modules/cloudflare/tiles/.terraform.lock.hcl index 160c4f7..3ee579f 100644 --- a/deployment/modules/cloudflare/tiles/.terraform.lock.hcl +++ b/deployment/modules/cloudflare/tiles/.terraform.lock.hcl @@ -2,37 +2,24 @@ # Manual edits may be lost in future updates. provider "registry.opentofu.org/cloudflare/cloudflare" { - version = "4.46.0" - constraints = "4.46.0" + version = "4.47.0" + constraints = "4.47.0" hashes = [ - "h1:3U4N3bbMacXTAdyaEwT305kETMETh1jZmGApmN6gdyE=", - "h1:3fhZhGNgtS9ugcZ2CIH6kk8LzN6yPxqOdkDUZqkP3+w=", - "h1:JWluJxBRSr8GVUhWVv83xse9SmbpwCLctCDddMXUnVk=", - "h1:KDHwakGt+3iBKXaoALCCAolPaJgpEHbkh3BfjnpuqoM=", - "h1:QFFZshAvwr9L5TQmsNQC6/sDqokk5pjbP8Ae4BQqMLQ=", - "h1:Qdi+vXwzDNii7ytSaOQtnlqhjZ3ZlRoUkFoi6CD2COI=", - "h1:TPcJXcVb/+C91hUuu8CEn98QUoNgLtnHfd4sgAOV+5k=", - "h1:WDy5wiNroXaCnw+r8rJnCP+J1RVsm2Qu3AOZ/iV4lLo=", - "h1:hMuL+dwHj3JbePqYcDrn/ZQN9R0WzeJX0AIDJ02Iteo=", - "h1:hQKCaUEARzJKbFt1CePP06E/+CiHWe/H6lc1AwK7y6w=", - "h1:l4DQ3WXmSzR/GBel3m2CRKWtaziVjBoxvUgL63t1GK0=", - "h1:nN9uVSLyrb/DjfZl6rPtCq5j0TX+6WypzNDexdzCQ08=", - "h1:rAX7njl6lKT9XIKMk6pLjVi7u/42wafRolWWgMHMkI0=", - "h1:t2IQYNu8YNykqYlEB+TTX+XpUd5z2flwGw8km9UgbnQ=", - "zh:2ee426ef3389022db0026792fdc4f2980dcf2600e31adf5a31b4bddfa8d68343", - "zh:2f993edb23df55dc1c18150fa187d80aa7d87e6439698ee34b6a6aad23ac2dd7", - "zh:3d6601333975e55979b1b454e50ff9a482ce4e0269dd6c72a50202163a8f4463", - "zh:4e5f48dce22f7a6d618018d65d1d443bb718defa23f514d5c6385860541fbe79", - "zh:5ebf5aea960fc30de381ffd6db20876d249673cf938fe67f1dfb6b9caa1db418", - "zh:80ed3fb901141f53b4b56ddb7eea5f2e0c0830d501387539d2c2b8e0cc7e587a", + "h1:jRNDuRaXbNFMLQZ298HoXodPUqI+4VVl8xgsCKAg5Yg=", + "zh:1df6a36bad08e95518987a15584e535a1dad5fa0ee6e067c0c39d709a285f6b9", + "zh:20dce2a63f24f571f4d52d3217811d71e8d21f149f751d5972ec19200674638a", + "zh:6571aeeb61d4a27b4210a1979028119a1905e162b0c3845e7b549d6e0a08c36d", + "zh:87ec7ebe65c8884e174999c22970e2f28b0da4e0f65bdc92db051eb3dd649f78", "zh:890df766e9b839623b1f0437355032a3c006226a6c200cd911e15ee1a9014e9f", - "zh:9aeae8b3be4a577ced46987fd9159262c5b4c54a510f66592fbcdb40fef55b10", - "zh:a0479ef2d308c4a7894f1fe77467cd07e04c7b40d281088f4f204af1bdf94ac6", - "zh:a2bdc0c25130665af0b9559942b9813a1ba4889513e7185d4abc9c02e9bb99bd", - "zh:b10be9755fe80395ced6f0bbda38b8c8681714cf1eca1d895be239c75c2ffc2a", - "zh:ba3d55e722d9f48646574ce7c448f0084fe21fa884b5f8b6d6146a82a99c4baa", - "zh:ec1fd0ecaedc787a77d5342b51ae8dea8362a67f1e19123f6521a0e8e012d9e8", - "zh:ed49590e69faef14550179f965b4451b31415b8f6be6d33427ad48f65c76b6cf", - "zh:f4baa3a2dac719ad20dcfa525bc3f737ad95650b8d0de0c648dc9a87f993b2c3", + "zh:a20d1c0865a9443ada90ab7c83bd8605024452cf1e9f3b2ed2efcf06221b7835", + "zh:a5a5a91f658029ae3bb0414643ca09bd6a98a1980e197a9eb2ea4ba96a190d88", + "zh:b12623a85840821c465b87b1d65542f8f4a77079afef0ad2cc102a9f6eb4045c", + "zh:b83ac4f0b81aee32b3670f5870245172741bb86b153623da687d3c45ec9c1af9", + "zh:bb1ad4fcb949b12e5b40a21e65963ff64e20e72ab4c87a3ec91306b440a2cf35", + "zh:cb5a8bc24444a9d8f536b5acb7f6346f12c03e23539b183cb370f4876992360f", + "zh:ce6cc02ac4fc8cdf48a64254fdb0ea859b5b48e7fc08c7f1fcb8e9364ed32434", + "zh:e44643c86d38799991f5eb2378c00ca4738ec0f21dd64536dadffd71a337d778", + "zh:e5024d6792fcaa974b5f294399eea9b9c7d3d5d228423e71941994858a20c58f", + "zh:f9b18d0443487e30e0f3b83e311f17c85d184dc9f55b3f9b31332e815c41745a", ] } diff --git a/deployment/modules/cloudflare/tiles/config.tf b/deployment/modules/cloudflare/tiles/config.tf index e2b58e0..09e2eba 100644 --- a/deployment/modules/cloudflare/tiles/config.tf +++ b/deployment/modules/cloudflare/tiles/config.tf @@ -7,7 +7,7 @@ terraform { required_providers { cloudflare = { source = "cloudflare/cloudflare" - version = "4.46.0" + version = "4.47.0" } } } From 9696ff2f167f01a2bf3d5d370900adb6caa30ac6 Mon Sep 17 00:00:00 2001 From: Zack Pollard Date: Wed, 27 Nov 2024 12:10:28 +0000 Subject: [PATCH 4/4] chore: cleanup unused variables --- deployment/modules/cloudflare/tiles/terragrunt.hcl | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/deployment/modules/cloudflare/tiles/terragrunt.hcl b/deployment/modules/cloudflare/tiles/terragrunt.hcl index e04b26e..0b1fa8b 100644 --- a/deployment/modules/cloudflare/tiles/terragrunt.hcl +++ b/deployment/modules/cloudflare/tiles/terragrunt.hcl @@ -9,13 +9,3 @@ terraform { include "root" { path = find_in_parent_folders("root.hcl") } - -locals { - tiles_build_dir = get_env("TF_VAR_tiles_build_dir") - vmetrics_api_token = get_env("TF_VAR_vmetrics_api_token") -} - -inputs = { - tiles_build_dir = local.tiles_build_dir - vmetrics_api_token = local.vmetrics_api_token -}