From c079ac9aa6563a8ea293eb24d35144d250da97c5 Mon Sep 17 00:00:00 2001 From: Luke Van Seters Date: Tue, 8 Feb 2022 15:36:45 -0500 Subject: [PATCH] Add region for the export bucket --- Tiltfile | 8 +++++--- k8s/mev-inspect-workers/templates/deployment.yaml | 10 ++++++++++ k8s/mev-inspect/templates/deployment.yaml | 5 +++++ mev_inspect/s3_export.py | 10 +++++++++- 4 files changed, 29 insertions(+), 4 deletions(-) diff --git a/Tiltfile b/Tiltfile index 4147dfa..7b324c7 100644 --- a/Tiltfile +++ b/Tiltfile @@ -97,11 +97,13 @@ local_resource( # if using local S3 exports # k8s_yaml(configmap_from_dict("mev-inspect-export", inputs = { # "export-bucket-name" : "local-export", +# "export-bucket-region": "us-east-1", # })) # -# helm_remote("localstack", -# repo_name="localstack-charts", -# repo_url="https://localstack.github.io/helm-charts", +# helm_remote( +# "localstack", +# repo_name="localstack-charts", +# repo_url="https://localstack.github.io/helm-charts", # ) # # local_resource( diff --git a/k8s/mev-inspect-workers/templates/deployment.yaml b/k8s/mev-inspect-workers/templates/deployment.yaml index 19486d1..63808da 100644 --- a/k8s/mev-inspect-workers/templates/deployment.yaml +++ b/k8s/mev-inspect-workers/templates/deployment.yaml @@ -91,6 +91,16 @@ spec: name: mev-inspect-listener-healthcheck key: url optional: true + - name: EXPORT_BUCKET_NAME + valueFrom: + configMapKeyRef: + name: mev-inspect-export + key: export-bucket-name + - name: EXPORT_BUCKET_REGION + valueFrom: + configMapKeyRef: + name: mev-inspect-export + key: export-bucket-region {{- range .Values.extraEnv }} - name: {{ .name }} value: {{ .value }} diff --git a/k8s/mev-inspect/templates/deployment.yaml b/k8s/mev-inspect/templates/deployment.yaml index fba11e0..4dda409 100644 --- a/k8s/mev-inspect/templates/deployment.yaml +++ b/k8s/mev-inspect/templates/deployment.yaml @@ -96,6 +96,11 @@ spec: configMapKeyRef: name: mev-inspect-export key: export-bucket-name + - name: EXPORT_BUCKET_REGION + valueFrom: + configMapKeyRef: + name: mev-inspect-export + key: export-bucket-region {{- range .Values.extraEnv }} - name: {{ .name }} value: {{ .value }} diff --git a/mev_inspect/s3_export.py b/mev_inspect/s3_export.py index c7ee60b..8477287 100644 --- a/mev_inspect/s3_export.py +++ b/mev_inspect/s3_export.py @@ -50,7 +50,11 @@ def export_block_range( def get_s3_client(): endpoint_url = get_endpoint_url() - return boto3.client("s3", endpoint_url=endpoint_url) + return boto3.client( + "s3", + endpoint_url=endpoint_url, + region_name=get_export_bucket_region(), + ) def get_endpoint_url() -> Optional[str]: @@ -59,3 +63,7 @@ def get_endpoint_url() -> Optional[str]: def get_export_bucket_name() -> str: return os.environ["EXPORT_BUCKET_NAME"] + + +def get_export_bucket_region() -> str: + return os.environ["EXPORT_BUCKET_REGION"]