Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add oceania R2 bucket and test regions that could benefit #62

Merged
merged 4 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/tiles-file.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
47 changes: 17 additions & 30 deletions deployment/modules/cloudflare/tiles-worker/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion deployment/modules/cloudflare/tiles-worker/config.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ terraform {
required_providers {
cloudflare = {
source = "cloudflare/cloudflare"
version = "4.46.0"
version = "4.47.0"
}
}
}
47 changes: 17 additions & 30 deletions deployment/modules/cloudflare/tiles/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion deployment/modules/cloudflare/tiles/config.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ terraform {
required_providers {
cloudflare = {
source = "cloudflare/cloudflare"
version = "4.46.0"
version = "4.47.0"
}
}
}
12 changes: 1 addition & 11 deletions deployment/modules/cloudflare/tiles/r2.tf
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
locals {
r2_regions = ["WNAM", "ENAM", "WEUR", "EEUR", "APAC"]
}

resource "cloudflare_r2_bucket" "tiles" {
account_id = var.cloudflare_account_id
name = "tiles"
r2_regions = ["WNAM", "ENAM", "WEUR", "EEUR", "APAC", "OC"]
}

resource "cloudflare_r2_bucket" "regional_tiles" {
Expand All @@ -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 }
}
10 changes: 0 additions & 10 deletions deployment/modules/cloudflare/tiles/terragrunt.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
34 changes: 17 additions & 17 deletions tiles/src/buckets.ts
Original file line number Diff line number Diff line change
@@ -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'],
Expand All @@ -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'],
Expand All @@ -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'],
Expand All @@ -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'],
Expand All @@ -72,38 +72,38 @@ 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'],
RIC: ['enam'],
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'],
Expand Down
1 change: 1 addition & 0 deletions tiles/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
Expand Down
17 changes: 9 additions & 8 deletions tiles/worker-configuration.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
zackpollard marked this conversation as resolved.
Show resolved Hide resolved
}
5 changes: 5 additions & 0 deletions tiles/wrangler.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down