From 5da794dabdff1dcfe77a2d5f3bf1cf84593dc206 Mon Sep 17 00:00:00 2001 From: Jennifer Tran <12633533+botanical@users.noreply.github.com> Date: Mon, 21 Oct 2024 11:11:53 -0700 Subject: [PATCH 1/3] feat: disable default api gateway endpoints --- ingest_api/infrastructure/construct.py | 1 + raster_api/infrastructure/construct.py | 1 + stac_api/infrastructure/construct.py | 1 + 3 files changed, 3 insertions(+) diff --git a/ingest_api/infrastructure/construct.py b/ingest_api/infrastructure/construct.py index d7dcd05f..f75fadac 100644 --- a/ingest_api/infrastructure/construct.py +++ b/ingest_api/infrastructure/construct.py @@ -211,6 +211,7 @@ def build_api( self, f"{stack_name}-{construct_id}", default_integration=ingest_api_integration, + disable_execute_api_endpoint=True, ) def build_jwks_url(self, userpool_id: str) -> str: diff --git a/raster_api/infrastructure/construct.py b/raster_api/infrastructure/construct.py index b75a9f21..6341b61c 100644 --- a/raster_api/infrastructure/construct.py +++ b/raster_api/infrastructure/construct.py @@ -99,6 +99,7 @@ def __init__( self, f"{stack_name}-{construct_id}", default_integration=raster_api_integration, + disable_execute_api_endpoint=True, ) CfnOutput( diff --git a/stac_api/infrastructure/construct.py b/stac_api/infrastructure/construct.py index c3ca56a0..3a76994d 100644 --- a/stac_api/infrastructure/construct.py +++ b/stac_api/infrastructure/construct.py @@ -106,6 +106,7 @@ def __init__( self, f"{stack_name}-{construct_id}", default_integration=stac_api_integration, + disable_execute_api_endpoint=True, ) CfnOutput( From 7afc9abd4de91cb86590e01c5b111717182f33db Mon Sep 17 00:00:00 2001 From: Jennifer Tran <12633533+botanical@users.noreply.github.com> Date: Tue, 22 Oct 2024 09:54:39 -0700 Subject: [PATCH 2/3] feat: add flag to disable default endpoints --- .example.env | 1 + config.py | 5 +++++ ingest_api/infrastructure/config.py | 5 +++++ ingest_api/infrastructure/construct.py | 4 +++- raster_api/infrastructure/config.py | 4 ++++ raster_api/infrastructure/construct.py | 2 +- stac_api/infrastructure/config.py | 4 ++++ stac_api/infrastructure/construct.py | 2 +- 8 files changed, 24 insertions(+), 3 deletions(-) diff --git a/.example.env b/.example.env index c3fb4b62..984a692e 100644 --- a/.example.env +++ b/.example.env @@ -40,3 +40,4 @@ VEDA_CLOUDFRONT= VEDA_CLOUDFRONT_OAC=[OPTIONAL, CONFIGURES ORIGIN ACCESS CONTROL, DEFAULTS TO TRUE] VEDA_CUSTOM_HOST= VEDA_SHARED_WEB_ACL_ID=[OPTIONAL ID ARN for WEB ACL] +VEDA_DISABLE_DEFAULT_APIGW_ENDPOINT=[OPTIONAL BOOL TO DISABLE DEFAULT API GATEWAY ENDPOINTS] diff --git a/config.py b/config.py index c792b1b7..83fd256d 100644 --- a/config.py +++ b/config.py @@ -109,6 +109,11 @@ class vedaAppSettings(BaseSettings): None, description="Custom domain name, i.e. veda-backend.xyz" ) + disable_default_apigw_endpoint: Optional[bool] = Field( + False, + description="Boolean to disable default API gateway endpoints for stac, raster, and ingest APIs. Defaults to false." + ) + def cdk_env(self) -> dict: """Load a cdk environment dict for stack""" diff --git a/ingest_api/infrastructure/config.py b/ingest_api/infrastructure/config.py index 31a894bb..1b3eadf7 100644 --- a/ingest_api/infrastructure/config.py +++ b/ingest_api/infrastructure/config.py @@ -88,6 +88,11 @@ class IngestorConfig(BaseSettings): description="Raster API root path. Used to infer url of raster-api before app synthesis.", ) + disable_default_apigw_endpoint: Optional[bool] = Field( + False, + description="Boolean to disable default API gateway endpoints for stac, raster, and ingest APIs. Defaults to false." + ) + class Config: case_sensitive = False env_file = ".env" diff --git a/ingest_api/infrastructure/construct.py b/ingest_api/infrastructure/construct.py index f75fadac..5f298b86 100644 --- a/ingest_api/infrastructure/construct.py +++ b/ingest_api/infrastructure/construct.py @@ -91,6 +91,7 @@ def __init__( construct_id=construct_id, handler=self.api_lambda, custom_host=config.custom_host, + disable_default_apigw_endpoint=config.disable_default_apigw_endpoint, ) stack_name = Stack.of(self).stack_name @@ -188,6 +189,7 @@ def build_api( construct_id: str, handler: aws_lambda.IFunction, custom_host: Optional[str], + disable_default_apigw_endpoint: Optional[bool], ) -> aws_apigatewayv2_alpha.HttpApi: integration_kwargs = dict(handler=handler) if custom_host: @@ -211,7 +213,7 @@ def build_api( self, f"{stack_name}-{construct_id}", default_integration=ingest_api_integration, - disable_execute_api_endpoint=True, + disable_execute_api_endpoint=disable_default_apigw_endpoint, ) def build_jwks_url(self, userpool_id: str) -> str: diff --git a/raster_api/infrastructure/config.py b/raster_api/infrastructure/config.py index f3474226..caa9ee23 100644 --- a/raster_api/infrastructure/config.py +++ b/raster_api/infrastructure/config.py @@ -84,6 +84,10 @@ class vedaRasterSettings(BaseSettings): "VEDA (Visualization, Exploration, and Data Analysis)", description="Name of the STAC Catalog", ) + disable_default_apigw_endpoint: Optional[bool] = Field( + False, + description="Boolean to disable default API gateway endpoints for stac, raster, and ingest APIs. Defaults to false." + ) class Config: """model config""" diff --git a/raster_api/infrastructure/construct.py b/raster_api/infrastructure/construct.py index 6341b61c..389e29f5 100644 --- a/raster_api/infrastructure/construct.py +++ b/raster_api/infrastructure/construct.py @@ -99,7 +99,7 @@ def __init__( self, f"{stack_name}-{construct_id}", default_integration=raster_api_integration, - disable_execute_api_endpoint=True, + disable_execute_api_endpoint=veda_raster_settings.disable_default_apigw_endpoint, ) CfnOutput( diff --git a/stac_api/infrastructure/config.py b/stac_api/infrastructure/config.py index 2196a430..52604f81 100644 --- a/stac_api/infrastructure/config.py +++ b/stac_api/infrastructure/config.py @@ -57,6 +57,10 @@ class vedaSTACSettings(BaseSettings): stac_enable_transactions: bool = Field( False, description="Whether to enable transactions endpoints" ) + disable_default_apigw_endpoint: Optional[bool] = Field( + False, + description="Boolean to disable default API gateway endpoints for stac, raster, and ingest APIs. Defaults to false." + ) @root_validator def check_transaction_fields(cls, values): diff --git a/stac_api/infrastructure/construct.py b/stac_api/infrastructure/construct.py index 3a76994d..10b4879b 100644 --- a/stac_api/infrastructure/construct.py +++ b/stac_api/infrastructure/construct.py @@ -106,7 +106,7 @@ def __init__( self, f"{stack_name}-{construct_id}", default_integration=stac_api_integration, - disable_execute_api_endpoint=True, + disable_execute_api_endpoint=veda_stac_settings.disable_default_apigw_endpoint, ) CfnOutput( From da2d01e0a652c3ba6ee27473158f7e6e3959fd14 Mon Sep 17 00:00:00 2001 From: Jennifer Tran <12633533+botanical@users.noreply.github.com> Date: Tue, 22 Oct 2024 10:41:14 -0700 Subject: [PATCH 3/3] fix: lint --- config.py | 2 +- ingest_api/infrastructure/config.py | 2 +- raster_api/infrastructure/config.py | 2 +- stac_api/infrastructure/config.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/config.py b/config.py index 83fd256d..93bb6d8c 100644 --- a/config.py +++ b/config.py @@ -111,7 +111,7 @@ class vedaAppSettings(BaseSettings): disable_default_apigw_endpoint: Optional[bool] = Field( False, - description="Boolean to disable default API gateway endpoints for stac, raster, and ingest APIs. Defaults to false." + description="Boolean to disable default API gateway endpoints for stac, raster, and ingest APIs. Defaults to false.", ) def cdk_env(self) -> dict: diff --git a/ingest_api/infrastructure/config.py b/ingest_api/infrastructure/config.py index 1b3eadf7..a4ca9d37 100644 --- a/ingest_api/infrastructure/config.py +++ b/ingest_api/infrastructure/config.py @@ -90,7 +90,7 @@ class IngestorConfig(BaseSettings): disable_default_apigw_endpoint: Optional[bool] = Field( False, - description="Boolean to disable default API gateway endpoints for stac, raster, and ingest APIs. Defaults to false." + description="Boolean to disable default API gateway endpoints for stac, raster, and ingest APIs. Defaults to false.", ) class Config: diff --git a/raster_api/infrastructure/config.py b/raster_api/infrastructure/config.py index caa9ee23..f5e5a055 100644 --- a/raster_api/infrastructure/config.py +++ b/raster_api/infrastructure/config.py @@ -86,7 +86,7 @@ class vedaRasterSettings(BaseSettings): ) disable_default_apigw_endpoint: Optional[bool] = Field( False, - description="Boolean to disable default API gateway endpoints for stac, raster, and ingest APIs. Defaults to false." + description="Boolean to disable default API gateway endpoints for stac, raster, and ingest APIs. Defaults to false.", ) class Config: diff --git a/stac_api/infrastructure/config.py b/stac_api/infrastructure/config.py index 52604f81..bba00ea4 100644 --- a/stac_api/infrastructure/config.py +++ b/stac_api/infrastructure/config.py @@ -59,7 +59,7 @@ class vedaSTACSettings(BaseSettings): ) disable_default_apigw_endpoint: Optional[bool] = Field( False, - description="Boolean to disable default API gateway endpoints for stac, raster, and ingest APIs. Defaults to false." + description="Boolean to disable default API gateway endpoints for stac, raster, and ingest APIs. Defaults to false.", ) @root_validator