From 6fd51cfb9b2e201977da4e9cee083441f622a467 Mon Sep 17 00:00:00 2001 From: anayeaye Date: Sun, 11 Dec 2022 16:42:41 -0700 Subject: [PATCH 1/3] rename variables: delta->veda --- .example.env | 20 ++++---- .github/workflows/tests/test_raster.py | 2 +- .github/workflows/tests/test_stac.py | 2 +- README.md | 38 +++++++------- app.py | 50 +++++++++---------- config.py | 16 +++--- database/infrastructure/config.py | 12 ++--- database/infrastructure/construct.py | 30 +++++------ docker-compose.yml | 10 ++-- domain/infrastructure/config.py | 10 ++-- domain/infrastructure/construct.py | 28 +++++------ network/infrastructure/construct.py | 20 ++++---- raster_api/infrastructure/config.py | 8 +-- raster_api/infrastructure/construct.py | 46 ++++++++--------- raster_api/runtime/README.md | 2 +- raster_api/runtime/setup.py | 6 +-- raster_api/runtime/src/__init__.py | 2 +- raster_api/runtime/src/app.py | 4 +- raster_api/runtime/src/config.py | 4 +- raster_api/runtime/src/dependencies.py | 2 +- setup.py | 8 +-- stac_api/infrastructure/config.py | 6 +-- stac_api/infrastructure/construct.py | 10 ++-- stac_api/runtime/README.md | 2 +- stac_api/runtime/setup.py | 4 +- stac_api/runtime/src/__init__.py | 2 +- stac_api/runtime/src/config.py | 4 +- .../standalone_app.py | 2 +- support_scripts/README.md | 4 +- support_scripts/rotate_pgstac_pasword.py | 2 +- 30 files changed, 178 insertions(+), 178 deletions(-) diff --git a/.example.env b/.example.env index 8b5f2f6d..02344b94 100644 --- a/.example.env +++ b/.example.env @@ -4,16 +4,16 @@ CDK_DEFAULT_REGION=[REQUIRED IF DEPLOYING TO EXISTING VPC] STAGE=[FILL ME IN] -DELTA_DB_PGSTAC_VERSION=0.6.6 -DELTA_DB_SCHEMA_VERSION=0.1.0 -DELTA_DB_SNAPSHOT_ID=[OPTIONAL BUT **REQUIRED** FOR ALL DEPLOYMENTS AFTER BASING DEPLOYMENT ON SNAPSHOT] +VEDA_DB_PGSTAC_VERSION=0.6.6 +VEDA_DB_SCHEMA_VERSION=0.1.0 +VEDA_DB_SNAPSHOT_ID=[OPTIONAL BUT **REQUIRED** FOR ALL DEPLOYMENTS AFTER BASING DEPLOYMENT ON SNAPSHOT] -DELTA_DOMAIN_HOSTED_ZONE_ID=[OPTIONAL] -DELTA_DOMAIN_HOSTED_ZONE_NAME=[OPTIONAL] -DELTA_DOMAIN_API_PREFIX=[OPTIONAL CUSTOM PREFIX DECOUPLES API URL FROM A/B VERSION OF STACK DEPLOYED] +VEDA_DOMAIN_HOSTED_ZONE_ID=[OPTIONAL] +VEDA_DOMAIN_HOSTED_ZONE_NAME=[OPTIONAL] +VEDA_DOMAIN_API_PREFIX=[OPTIONAL CUSTOM PREFIX DECOUPLES API URL FROM A/B VERSION OF STACK DEPLOYED] -DELTA_DOMAIN_ALT_HOSTED_ZONE_ID=[OPTIONAL SECOND HOSTED ZONE] -DELTA_DOMAIN_ALT_HOSTED_ZONE_NAME=[OPTIONAL SECOND DOMAIN] +VEDA_DOMAIN_ALT_HOSTED_ZONE_ID=[OPTIONAL SECOND HOSTED ZONE] +VEDA_DOMAIN_ALT_HOSTED_ZONE_NAME=[OPTIONAL SECOND DOMAIN] -DELTA_RASTER_ENABLE_MOSAIC_SEARCH=TRUE -DELTA_RASTER_DATA_ACCESS_ROLE_ARN=[OPTIONAL ARN OF IAM ROLE TO BE ASSUMED BY RASTER API] +VEDA_RASTER_ENABLE_MOSAIC_SEARCH=TRUE +VEDA_RASTER_DATA_ACCESS_ROLE_ARN=[OPTIONAL ARN OF IAM ROLE TO BE ASSUMED BY RASTER API] diff --git a/.github/workflows/tests/test_raster.py b/.github/workflows/tests/test_raster.py index 19019736..0da4adc8 100644 --- a/.github/workflows/tests/test_raster.py +++ b/.github/workflows/tests/test_raster.py @@ -1,4 +1,4 @@ -"""test delta-backend.raster.""" +"""test veda-backend.raster.""" import httpx diff --git a/.github/workflows/tests/test_stac.py b/.github/workflows/tests/test_stac.py index bd94ec5d..0bdc80d7 100644 --- a/.github/workflows/tests/test_stac.py +++ b/.github/workflows/tests/test_stac.py @@ -1,4 +1,4 @@ -"""test Delta-backend STAC.""" +"""test veda-backend STAC.""" import httpx diff --git a/README.md b/README.md index 3120033c..586d2087 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -# delta-backend -This project deploys a complete backend for a [SpatioTemporal Asset Catalog](https://stacspec.org/) including a postgres database, a metadata API, and raster tiling API. Delta-backend is a non-forked version of the [eoAPI](https://github.com/developmentseed/eoAPI) demo project. Delta-backend is decoupled from the demo project to selectively incorporate new stable functionality from the fast moving development in eoAPI while providing a continuous baseline for delta-backend users and to support project specific business and deployment logic. +# veda-backend +This project deploys a complete backend for a [SpatioTemporal Asset Catalog](https://stacspec.org/) including a postgres database, a metadata API, and raster tiling API. Veda-backend is a non-forked version of the [eoAPI](https://github.com/developmentseed/eoAPI) demo project. Veda-backend is decoupled from the demo project to selectively incorporate new stable functionality from the fast moving development in eoAPI while providing a continuous baseline for veda-backend users and to support project specific business and deployment logic. The primary tools employed in the [eoAPI demo](https://github.com/developmentseed/eoAPI) and this project are: - [stac-spec](https://github.com/radiantearth/stac-spec) @@ -20,7 +20,7 @@ This repo includes CDK scripts to deploy a PgStac AWS RDS database and other res ### Enviroment variables -An [.example.env](.example.env) template is supplied for for local deployments. If updating an existing deployment, it is essential to check the most current values for these variables by fetching these values from AWS Secrets Manager. The environment secrets are named `-backend/-env`, for example `delta-backend/dev-env`. +An [.example.env](.example.env) template is supplied for for local deployments. If updating an existing deployment, it is essential to check the most current values for these variables by fetching these values from AWS Secrets Manager. The environment secrets are named `-backend/-env`, for example `veda-backend/dev-env`. ### Fetch environment variables using AWS CLI @@ -35,23 +35,23 @@ aws secretsmanager get-secret-value --secret-id ${AWS_SECRET_ID} --query SecretS | Name | Explanation | | --- | --- | -| `APP_NAME` | Optional app name used to name stack and resources, defaults to `delta` | +| `APP_NAME` | Optional app name used to name stack and resources, defaults to `veda` | | `STAGE` | **REQUIRED** Deployment stage used to name stack and resources, i.e. `dev`, `staging`, `prod` | | `VPC_ID` | Optional resource identifier of VPC, if none a new VPC with public and private subnets will be provisioned. | | `PERMISSIONS_BOUNDARY_POLICY_NAME` | Optional name of IAM policy to define stack permissions boundary | | `CDK_DEFAULT_ACCOUNT` | When deploying from a local machine the AWS account id is required to deploy to an exiting VPC | | `CDK_DEFAULT_REGION` | When deploying from a local machine the AWS region id is required to deploy to an exiting VPC | -| `DELTA_DB_PGSTAC_VERSION` | **REQUIRED** version of PgStac database, i.e. 0.5 | -| `DELTA_DB_SCHEMA_VERSION` | **REQUIRED** The version of the custom delta-backend schema, i.e. 0.1.1 | -| `DELTA_DB_SNAPSHOT_ID` | **Once used always REQUIRED** Optional RDS snapshot identifier to initialize RDS from a snapshot | -| `DELTA_DB_PRIVATE_SUBNETS` | Optional boolean to deploy database to private subnet | -| `DELTA_DOMAIN_HOSTED_ZONE_ID` | Optional Route53 zone identifier if using a custom domain name | -| `DELTA_DOMAIN_HOSTED_ZONE_NAME` | Optional custom domain name, i.e. delta-backend.xyz | -| `DELTA_DOMAIN_ALT_HOSTED_ZONE_ID` | Optional second Route53 zone identifier if using a custom domain name | -| `DELTA_DOMAIN_ALT_HOSTED_ZONE_NAME` | Optional second custom domain name, i.e. alt-delta-backend.xyz | -| `DELTA_DOMAIN_API_PREFIX` | Optional domain prefix override supports using a custom prefix instead of the STAGE variabe (an alternate version of the stack can be deployed with a unique STAGE=altprod and after testing prod API traffic can be cut over to the alternate version of the stack by setting the prefix to prod) | -| `DELTA_RASTER_ENABLE_MOSAIC_SEARCH` | Optional deploy the raster API with the mosaic/list endpoint TRUE/FALSE | -| `DELTA_RASTER_DATA_ACCESS_ROLE_ARN` | Optional arn of IAM Role to be assumed by raster-api for S3 bucket data access, if not provided default role for the lambda construct is used | +| `VEDA_DB_PGSTAC_VERSION` | **REQUIRED** version of PgStac database, i.e. 0.5 | +| `VEDA_DB_SCHEMA_VERSION` | **REQUIRED** The version of the custom veda-backend schema, i.e. 0.1.1 | +| `VEDA_DB_SNAPSHOT_ID` | **Once used always REQUIRED** Optional RDS snapshot identifier to initialize RDS from a snapshot | +| `VEDA_DB_PRIVATE_SUBNETS` | Optional boolean to deploy database to private subnet | +| `VEDA_DOMAIN_HOSTED_ZONE_ID` | Optional Route53 zone identifier if using a custom domain name | +| `VEDA_DOMAIN_HOSTED_ZONE_NAME` | Optional custom domain name, i.e. veda-backend.xyz | +| `VEDA_DOMAIN_ALT_HOSTED_ZONE_ID` | Optional second Route53 zone identifier if using a custom domain name | +| `VEDA_DOMAIN_ALT_HOSTED_ZONE_NAME` | Optional second custom domain name, i.e. alt-veda-backend.xyz | +| `VEDA_DOMAIN_API_PREFIX` | Optional domain prefix override supports using a custom prefix instead of the STAGE variabe (an alternate version of the stack can be deployed with a unique STAGE=altprod and after testing prod API traffic can be cut over to the alternate version of the stack by setting the prefix to prod) | +| `VEDA_RASTER_ENABLE_MOSAIC_SEARCH` | Optional deploy the raster API with the mosaic/list endpoint TRUE/FALSE | +| `VEDA_RASTER_DATA_ACCESS_ROLE_ARN` | Optional arn of IAM Role to be assumed by raster-api for S3 bucket data access, if not provided default role for the lambda construct is used | ### Deploying to the cloud @@ -69,15 +69,15 @@ python3 -m pip install -e ".[dev,deploy,test]" #### Run the deployment ``` -cdk synth +# Review what infrastructure changes your deployment will cause +cdk diff +# Execute deployment, security changes will require approval for deployment cdk deploy ``` #### Check CloudFormation deployment status After logging in to the console at https://.signin.aws.amazon.com/console the status of the CloudFormation stack can be viewed here: https://.console.aws.amazon.com/cloudformation/home. - -The CloudFormation stack name is the combination of the app name and deployment stage environment variables https://github.com/NASA-IMPACT/delta-backend/blob/develop/config.py#L11 ## Deleting the CloudFormation stack @@ -186,7 +186,7 @@ https://github.com/NASA-IMPACT/veda-documentation # STAC community resources ## STAC browser -Radiant Earth's [stac-browser](https://github.com/radiantearth/stac-browser) is a browser for STAC catalogs. The demo version of this browser [radiantearth.github.io/stac-browser](https://radiantearth.github.io/stac-browser/#/) can be used to browse the contents of the delta-backend STAC catalog, paste the delta-backend stac-api URL deployed by this project in the demo and click load. Read more about the recent developments and usage of stac-browser [here](https://medium.com/radiant-earth-insights/the-exciting-future-of-the-stac-browser-2351143aa24b). +Radiant Earth's [stac-browser](https://github.com/radiantearth/stac-browser) is a browser for STAC catalogs. The demo version of this browser [radiantearth.github.io/stac-browser](https://radiantearth.github.io/stac-browser/#/) can be used to browse the contents of the veda-backend STAC catalog, paste the veda-backend stac-api URL deployed by this project in the demo and click load. Read more about the recent developments and usage of stac-browser [here](https://medium.com/radiant-earth-insights/the-exciting-future-of-the-stac-browser-2351143aa24b). # License This project is licensed under **Apache 2**, see the [LICENSE](LICENSE) file for more details. \ No newline at end of file diff --git a/app.py b/app.py index bec2fc90..8f28356b 100644 --- a/app.py +++ b/app.py @@ -1,10 +1,10 @@ #!/usr/bin/env python3 -""" CDK Configuration for the delta-backend stack.""" +""" CDK Configuration for the veda-backend stack.""" from aws_cdk import App, Stack, Tags, aws_iam from constructs import Construct -from config import delta_app_settings +from config import veda_app_settings from database.infrastructure.construct import RdsConstruct from domain.infrastructure.construct import DomainConstruct from network.infrastructure.construct import VpcConstruct @@ -14,46 +14,46 @@ app = App() -class DeltaStack(Stack): - """CDK stack for the delta-backend stack.""" +class VedaStack(Stack): + """CDK stack for the veda-backend stack.""" def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None: """.""" super().__init__(scope, construct_id, **kwargs) - if delta_app_settings.permissions_boundary_policy_name: + if veda_app_settings.permissions_boundary_policy_name: permission_boundary_policy = aws_iam.Policy.from_policy_name( self, "permission-boundary", - delta_app_settings.permissions_boundary_policy_name, + veda_app_settings.permissions_boundary_policy_name, ) aws_iam.PermissionsBoundary.of(self).apply(permission_boundary_policy) -delta_stack = DeltaStack( +veda_stack = VedaStack( app, - f"{delta_app_settings.app_name}-{delta_app_settings.stage_name()}", - env=delta_app_settings.cdk_env(), + f"{veda_app_settings.app_name}-{veda_app_settings.stage_name()}", + env=veda_app_settings.cdk_env(), ) -if delta_app_settings.vpc_id: +if veda_app_settings.vpc_id: vpc = VpcConstruct( - delta_stack, + veda_stack, "network", - vpc_id=delta_app_settings.vpc_id, - stage=delta_app_settings.stage_name(), + vpc_id=veda_app_settings.vpc_id, + stage=veda_app_settings.stage_name(), ) else: - vpc = VpcConstruct(delta_stack, "network", stage=delta_app_settings.stage_name()) + vpc = VpcConstruct(veda_stack, "network", stage=veda_app_settings.stage_name()) database = RdsConstruct( - delta_stack, "database", vpc.vpc, stage=delta_app_settings.stage_name() + veda_stack, "database", vpc.vpc, stage=veda_app_settings.stage_name() ) -domain = DomainConstruct(delta_stack, "domain", stage=delta_app_settings.stage_name()) +domain = DomainConstruct(veda_stack, "domain", stage=veda_app_settings.stage_name()) raster_api = RasterApiLambdaConstruct( - delta_stack, + veda_stack, "raster-api", vpc=vpc.vpc, database=database, @@ -61,7 +61,7 @@ def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None: ) stac_api = StacApiLambdaConstruct( - delta_stack, + veda_stack, "stac-api", vpc=vpc.vpc, database=database, @@ -70,17 +70,17 @@ def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None: ) # TODO this conditional supports deploying a second set of APIs to a separate custom domain and should be removed if no longer necessary -if delta_app_settings.alt_domain(): +if veda_app_settings.alt_domain(): alt_domain = DomainConstruct( - delta_stack, + veda_stack, "alt-domain", - stage=delta_app_settings.stage_name(), + stage=veda_app_settings.stage_name(), alt_domain=True, ) alt_raster_api = RasterApiLambdaConstruct( - delta_stack, + veda_stack, "alt-raster-api", vpc=vpc.vpc, database=database, @@ -88,7 +88,7 @@ def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None: ) alt_stac_api = StacApiLambdaConstruct( - delta_stack, + veda_stack, "alt-stac-api", vpc=vpc.vpc, database=database, @@ -97,8 +97,8 @@ def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None: ) for key, value in { - "Project": delta_app_settings.app_name, - "Stack": delta_app_settings.stage_name(), + "Project": veda_app_settings.app_name, + "Stack": veda_app_settings.stage_name(), "Client": "nasa-impact", "Owner": "ds", }.items(): diff --git a/config.py b/config.py index fcda022e..cd461c6a 100644 --- a/config.py +++ b/config.py @@ -4,12 +4,12 @@ from pydantic import BaseSettings, Field -class deltaAppSettings(BaseSettings): +class vedaAppSettings(BaseSettings): """Application settings.""" # App name and deployment stage app_name: Optional[str] = Field( - "delta-backend", + "veda-backend", description="Optional app name used to name stack and resources", ) stage: str = Field( @@ -38,13 +38,13 @@ class deltaAppSettings(BaseSettings): None, description="Name of IAM policy to define stack permissions boundary", ) - delta_domain_alt_hosted_zone_id: Optional[str] = Field( + veda_domain_alt_hosted_zone_id: Optional[str] = Field( None, description="Route53 zone identifier if using a custom domain name", ) - delta_domain_alt_hosted_zone_name: Optional[str] = Field( + veda_domain_alt_hosted_zone_name: Optional[str] = Field( None, - description="Custom domain name, i.e. delta-backend.xyz", + description="Custom domain name, i.e. veda-backend.xyz", ) def cdk_env(self) -> dict: @@ -62,8 +62,8 @@ def alt_domain(self) -> bool: """True if alternative domain and host parameters provided""" return all( [ - self.delta_domain_alt_hosted_zone_id, - self.delta_domain_alt_hosted_zone_name, + self.veda_domain_alt_hosted_zone_id, + self.veda_domain_alt_hosted_zone_name, ] ) @@ -77,4 +77,4 @@ class Config: env_file = ".env" -delta_app_settings = deltaAppSettings() +veda_app_settings = vedaAppSettings() diff --git a/database/infrastructure/config.py b/database/infrastructure/config.py index e440023d..6cb15baa 100644 --- a/database/infrastructure/config.py +++ b/database/infrastructure/config.py @@ -1,10 +1,10 @@ -"""Delta-backend database construct configuration.""" +"""Veda-backend database construct configuration.""" from typing import Optional from pydantic import BaseSettings, Field -class deltaDBSettings(BaseSettings): +class vedaDBSettings(BaseSettings): """Application settings.""" dbname: str = Field( @@ -16,7 +16,7 @@ class deltaDBSettings(BaseSettings): description="Name of admin role for postgres database", ) user: str = Field( - "delta", + "veda", description="Name of pgstac role for postgres database", ) pgstac_version: str = Field( @@ -25,7 +25,7 @@ class deltaDBSettings(BaseSettings): ) schema_version: str = Field( ..., - description="The version of the custom delta-backend schema, i.e. 0.1.1", + description="The version of the custom veda-backend schema, i.e. 0.1.1", ) snapshot_id: Optional[str] = Field( None, @@ -60,7 +60,7 @@ class Config: """model config.""" env_file = ".env" - env_prefix = "DELTA_DB_" + env_prefix = "VEDA_DB_" -delta_db_settings = deltaDBSettings() +veda_db_settings = vedaDBSettings() diff --git a/database/infrastructure/construct.py b/database/infrastructure/construct.py index f1257eca..6f17279f 100644 --- a/database/infrastructure/construct.py +++ b/database/infrastructure/construct.py @@ -1,4 +1,4 @@ -"""CDK Construct for delta-backend RDS instance.""" +"""CDK Construct for veda-backend RDS instance.""" import json import os from typing import Union @@ -17,7 +17,7 @@ ) from constructs import Construct -from .config import delta_db_settings +from .config import veda_db_settings # https://github.com/developmentseed/eoAPI/blob/master/deployment/cdk/app.py @@ -39,8 +39,8 @@ def __init__( """.""" super().__init__(scope, construct_id) - pgstac_version = delta_db_settings.pgstac_version - delta_schema_version = delta_db_settings.schema_version + pgstac_version = veda_db_settings.pgstac_version + veda_schema_version = veda_db_settings.schema_version handler = aws_lambda.Function( self, @@ -97,7 +97,7 @@ def __init__( "pgstac_version": pgstac_version, "conn_secret_arn": database.secret.secret_arn, "new_user_secret_arn": self.secret.secret_arn, - "delta_schema_version": delta_schema_version, + "veda_schema_version": veda_schema_version, }, removal_policy=RemovalPolicy.RETAIN, # This retains the custom resource (which doesn't really exist), not the database ) @@ -127,10 +127,10 @@ def __init__( stack_name = Stack.of(self).stack_name # Configure accessibility - publicly_accessible = False if delta_db_settings.private_subnets else True + publicly_accessible = False if veda_db_settings.private_subnets else True subnet_type = ( aws_ec2.SubnetType.PRIVATE_ISOLATED - if delta_db_settings.private_subnets is True + if veda_db_settings.private_subnets is True else aws_ec2.SubnetType.PUBLIC ) @@ -143,23 +143,23 @@ def __init__( "parameter-group", engine=engine, parameters={ - "max_locks_per_transaction": delta_db_settings.max_locks_per_transaction, - "work_mem": delta_db_settings.work_mem, - "temp_buffers": delta_db_settings.temp_buffers, + "max_locks_per_transaction": veda_db_settings.max_locks_per_transaction, + "work_mem": veda_db_settings.work_mem, + "temp_buffers": veda_db_settings.temp_buffers, }, ) # Create a new database instance from snapshot if provided - if delta_db_settings.snapshot_id: + if veda_db_settings.snapshot_id: # For the database from snapshot we will need a new master secret credentials = aws_rds.SnapshotCredentials.from_generated_secret( - username=delta_db_settings.admin_user + username=veda_db_settings.admin_user ) database = aws_rds.DatabaseInstanceFromSnapshot( self, id="rds", - snapshot_identifier=delta_db_settings.snapshot_id, + snapshot_identifier=veda_db_settings.snapshot_id, instance_identifier=f"{stack_name}-postgres", vpc=vpc, engine=engine, @@ -197,8 +197,8 @@ def __init__( self, "pgstac", database=database, - new_dbname=delta_db_settings.dbname, - new_username=delta_db_settings.user, + new_dbname=veda_db_settings.dbname, + new_username=veda_db_settings.user, secrets_prefix=stack_name, stage=stage, ) diff --git a/docker-compose.yml b/docker-compose.yml index 0522cb4a..395e6a54 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,7 +2,7 @@ version: '3' services: stac: - container_name: delta.stac + container_name: veda.stac build: context: . dockerfile: local/Dockerfile.stac @@ -40,7 +40,7 @@ services: - ./scripts:/tmp/scripts raster: - container_name: delta.raster + container_name: veda.raster platform: linux/amd64 build: context: . @@ -83,7 +83,7 @@ services: - AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID} - AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY} # API Config - - DELTA_RASTER_ENABLE_MOSAIC_SEARCH=TRUE + - VEDA_RASTER_ENABLE_MOSAIC_SEARCH=TRUE depends_on: - database @@ -93,7 +93,7 @@ services: - $HOME/.aws/credentials:/root/.aws/credentials database: - container_name: delta.db + container_name: veda.db platform: linux/amd64 image: ghcr.io/stac-utils/pgstac:v0.6.6 environment: @@ -112,4 +112,4 @@ services: networks: default: - name: delta-network + name: veda-network diff --git a/domain/infrastructure/config.py b/domain/infrastructure/config.py index bfb6d999..e2b52a87 100644 --- a/domain/infrastructure/config.py +++ b/domain/infrastructure/config.py @@ -5,14 +5,14 @@ from pydantic import BaseSettings, Field -class deltaDomainSettings(BaseSettings): +class vedaDomainSettings(BaseSettings): """Application settings""" hosted_zone_id: Optional[str] = Field( None, description="Route53 hosted zone identifier if using a custom domain name" ) hosted_zone_name: Optional[str] = Field( - None, description="Custom domain name, i.e. delta-backend.xyz" + None, description="Custom domain name, i.e. veda-backend.xyz" ) api_prefix: Optional[str] = Field( None, @@ -29,14 +29,14 @@ class deltaDomainSettings(BaseSettings): None, description="Second Route53 zone identifier if using a custom domain name" ) alt_hosted_zone_name: Optional[str] = Field( - None, description="Second custom domain name, i.e. alt-delta-backend.xyz" + None, description="Second custom domain name, i.e. alt-veda-backend.xyz" ) class Config: """model config""" env_file = ".env" - env_prefix = "DELTA_DOMAIN_" + env_prefix = "VEDA_DOMAIN_" -delta_domain_settings = deltaDomainSettings() +veda_domain_settings = vedaDomainSettings() diff --git a/domain/infrastructure/construct.py b/domain/infrastructure/construct.py index aea57d38..9efd0011 100644 --- a/domain/infrastructure/construct.py +++ b/domain/infrastructure/construct.py @@ -1,4 +1,4 @@ -"""CDK Construct for a custom API domain (under the route 53 domain: delta-backend.xyz).""" +"""CDK Construct for a custom API domain.""" from typing import Optional from aws_cdk import ( @@ -10,11 +10,11 @@ ) from constructs import Construct -from .config import delta_domain_settings +from .config import veda_domain_settings class DomainConstruct(Construct): - """CDK Construct for a custom API domain (under the route 53 domain: delta-backend.xyz).""" + """CDK Construct for a custom API domain.""" def __init__( self, @@ -31,16 +31,16 @@ def __init__( self.raster_domain_name = None if ( - delta_domain_settings.hosted_zone_id - and delta_domain_settings.hosted_zone_name + veda_domain_settings.hosted_zone_id + and veda_domain_settings.hosted_zone_name ): # If alternative custom domain provided, use it instead of the default if alt_domain is True: - hosted_zone_name = delta_domain_settings.alt_hosted_zone_name - hosted_zone_id = delta_domain_settings.alt_hosted_zone_id + hosted_zone_name = veda_domain_settings.alt_hosted_zone_name + hosted_zone_id = veda_domain_settings.alt_hosted_zone_id else: - hosted_zone_name = delta_domain_settings.hosted_zone_name - hosted_zone_id = delta_domain_settings.hosted_zone_id + hosted_zone_name = veda_domain_settings.hosted_zone_name + hosted_zone_id = veda_domain_settings.hosted_zone_id hosted_zone = aws_route53.HostedZone.from_hosted_zone_attributes( self, @@ -58,9 +58,9 @@ def __init__( ) # Use custom api prefix if provided or deployment stage if not - if delta_domain_settings.api_prefix: - raster_url_prefix = f"{delta_domain_settings.api_prefix.lower()}-raster" - stac_url_prefix = f"{delta_domain_settings.api_prefix.lower()}-stac" + if veda_domain_settings.api_prefix: + raster_url_prefix = f"{veda_domain_settings.api_prefix.lower()}-raster" + stac_url_prefix = f"{veda_domain_settings.api_prefix.lower()}-stac" else: raster_url_prefix = f"{stage.lower()}-raster" stac_url_prefix = f"{stage.lower()}-stac" @@ -84,7 +84,7 @@ def __init__( regional_hosted_zone_id=self.raster_domain_name.regional_hosted_zone_id, ) ), - # Note: CDK will append the hosted zone name (eg: `delta-backend.xyz` to this record name) + # Note: CDK will append the hosted zone name (eg: `veda-backend.xyz` to this record name) record_name=raster_url_prefix, ) @@ -105,7 +105,7 @@ def __init__( regional_hosted_zone_id=self.stac_domain_name.regional_hosted_zone_id, ) ), - # Note: CDK will append the hosted zone name (eg: `delta-backend.xyz` to this record name) + # Note: CDK will append the hosted zone name (eg: `veda-backend.xyz` to this record name) record_name=stac_url_prefix, ) diff --git a/network/infrastructure/construct.py b/network/infrastructure/construct.py index 88c48da9..fa8cd3c7 100644 --- a/network/infrastructure/construct.py +++ b/network/infrastructure/construct.py @@ -1,5 +1,5 @@ """ -CDK construct for delta-backend VPC. +CDK construct for veda-backend VPC. """ from typing import Optional @@ -12,7 +12,7 @@ # https://github.com/aws-samples/aws-cdk-examples/tree/master/python/new-vpc-alb-asg-mysql # https://github.com/aws-samples/aws-cdk-examples/tree/master/python/docker-app-with-asg-alb class VpcConstruct(Construct): - """CDK construct for delta-backend VPC.""" + """CDK construct for veda-backend VPC.""" def __init__( self, @@ -35,30 +35,30 @@ def __init__( else: # Union of pydantic base settings is unpredictable so set stage settings conditionally if stage == "prod": - delta_vpc_settings = prod_vpc_settings + veda_vpc_settings = prod_vpc_settings elif stage == "staging": - delta_vpc_settings = staging_vpc_settings + veda_vpc_settings = staging_vpc_settings else: - delta_vpc_settings = dev_vpc_settings + veda_vpc_settings = dev_vpc_settings public_subnet = aws_ec2.SubnetConfiguration( name="public", subnet_type=aws_ec2.SubnetType.PUBLIC, - cidr_mask=delta_vpc_settings.public_mask, + cidr_mask=veda_vpc_settings.public_mask, ) private_subnet = aws_ec2.SubnetConfiguration( name="private", subnet_type=aws_ec2.SubnetType.PRIVATE_WITH_NAT, - cidr_mask=delta_vpc_settings.private_mask, + cidr_mask=veda_vpc_settings.private_mask, ) self.vpc = aws_ec2.Vpc( self, "vpc", - max_azs=delta_vpc_settings.max_azs, - cidr=delta_vpc_settings.cidr, + max_azs=veda_vpc_settings.max_azs, + cidr=veda_vpc_settings.cidr, subnet_configuration=[public_subnet, private_subnet], - nat_gateways=delta_vpc_settings.nat_gateways, + nat_gateways=veda_vpc_settings.nat_gateways, ) vpc_endpoints = { diff --git a/raster_api/infrastructure/config.py b/raster_api/infrastructure/config.py index 635e1657..586b5dc3 100644 --- a/raster_api/infrastructure/config.py +++ b/raster_api/infrastructure/config.py @@ -1,12 +1,12 @@ """Settings for Raster API - any environment variables starting with -`DELTA_RASTER_` will overwrite the values of variables in this file +`VEDA_RASTER_` will overwrite the values of variables in this file """ from typing import Dict, List, Optional from pydantic import BaseSettings, Field -class deltaRasterSettings(BaseSettings): +class vedaRasterSettings(BaseSettings): """Application settings""" # Default options are optimized for CloudOptimized GeoTIFF @@ -63,7 +63,7 @@ class Config: """model config""" env_file = ".env" - env_prefix = "DELTA_RASTER_" + env_prefix = "VEDA_RASTER_" -delta_raster_settings = deltaRasterSettings() +veda_raster_settings = vedaRasterSettings() diff --git a/raster_api/infrastructure/construct.py b/raster_api/infrastructure/construct.py index 4dc6d78b..118e4257 100644 --- a/raster_api/infrastructure/construct.py +++ b/raster_api/infrastructure/construct.py @@ -14,7 +14,7 @@ ) from constructs import Construct -from .config import delta_raster_settings +from .config import veda_raster_settings class RasterApiLambdaConstruct(Construct): @@ -36,7 +36,7 @@ def __init__( # TODO config stack_name = Stack.of(self).stack_name - delta_raster_function = aws_lambda.Function( + veda_raster_function = aws_lambda.Function( self, "lambda", runtime=aws_lambda.Runtime.PYTHON_3_8, @@ -48,30 +48,30 @@ def __init__( vpc=vpc, allow_public_subnet=True, handler="handler.handler", - memory_size=delta_raster_settings.memory, - timeout=Duration.seconds(delta_raster_settings.timeout), + memory_size=veda_raster_settings.memory, + timeout=Duration.seconds(veda_raster_settings.timeout), log_retention=aws_logs.RetentionDays.ONE_WEEK, - environment=delta_raster_settings.env or {}, + environment=veda_raster_settings.env or {}, tracing=aws_lambda.Tracing.ACTIVE, ) - database.pgstac.secret.grant_read(delta_raster_function) + database.pgstac.secret.grant_read(veda_raster_function) database.pgstac.connections.allow_from( - delta_raster_function, port_range=aws_ec2.Port.tcp(5432) + veda_raster_function, port_range=aws_ec2.Port.tcp(5432) ) - delta_raster_function.add_environment( - "DELTA_RASTER_ENABLE_MOSAIC_SEARCH", - str(delta_raster_settings.enable_mosaic_search), + veda_raster_function.add_environment( + "VEDA_RASTER_ENABLE_MOSAIC_SEARCH", + str(veda_raster_settings.enable_mosaic_search), ) - delta_raster_function.add_environment( - "DELTA_RASTER_PGSTAC_SECRET_ARN", database.pgstac.secret.secret_full_arn + veda_raster_function.add_environment( + "VEDA_RASTER_PGSTAC_SECRET_ARN", database.pgstac.secret.secret_full_arn ) raster_api_integration = ( aws_apigatewayv2_integrations_alpha.HttpLambdaIntegration( - construct_id, delta_raster_function + construct_id, veda_raster_function ) ) @@ -89,34 +89,34 @@ def __init__( ) CfnOutput(self, "raster-api", value=self.raster_api.url) - CfnOutput(self, "raster-api-arn", value=delta_raster_function.function_arn) + CfnOutput(self, "raster-api-arn", value=veda_raster_function.function_arn) - delta_raster_function.add_to_role_policy( + veda_raster_function.add_to_role_policy( aws_iam.PolicyStatement( actions=["s3:GetObject"], resources=[ - f"arn:aws:s3:::{bucket}/{delta_raster_settings.key}" - for bucket in delta_raster_settings.buckets + f"arn:aws:s3:::{bucket}/{veda_raster_settings.key}" + for bucket in veda_raster_settings.buckets ], ) ) # Optional use sts assume role with GetObject permissions for external S3 bucket(s) - if delta_raster_settings.data_access_role_arn: + if veda_raster_settings.data_access_role_arn: # Get the role for external data access data_access_role = aws_iam.Role.from_role_arn( self, "data-access-role", - delta_raster_settings.data_access_role_arn, + veda_raster_settings.data_access_role_arn, ) # Allow this lambda to assume the data access role data_access_role.grant( - delta_raster_function.grant_principal, + veda_raster_function.grant_principal, "sts:AssumeRole", ) - delta_raster_function.add_environment( - "DELTA_RASTER_DATA_ACCESS_ROLE_ARN", - delta_raster_settings.data_access_role_arn, + veda_raster_function.add_environment( + "VEDA_RASTER_DATA_ACCESS_ROLE_ARN", + veda_raster_settings.data_access_role_arn, ) diff --git a/raster_api/runtime/README.md b/raster_api/runtime/README.md index b0646eb9..202a6236 100644 --- a/raster_api/runtime/README.md +++ b/raster_api/runtime/README.md @@ -1 +1 @@ -## delta.raster_api +## veda.raster_api diff --git a/raster_api/runtime/setup.py b/raster_api/runtime/setup.py index 034b6ec9..9501c0b3 100644 --- a/raster_api/runtime/setup.py +++ b/raster_api/runtime/setup.py @@ -1,4 +1,4 @@ -"""Setup delta.raster_api.""" +"""Setup veda.raster_api.""" from setuptools import find_namespace_packages, setup @@ -24,11 +24,11 @@ setup( - name="delta.raster_api", + name="veda.raster_api", description="", python_requires=">=3.7", packages=find_namespace_packages(exclude=["tests*"]), - package_data={"delta": ["raster/templates/*.html"]}, + package_data={"veda": ["raster/templates/*.html"]}, include_package_data=True, zip_safe=False, install_requires=inst_reqs, diff --git a/raster_api/runtime/src/__init__.py b/raster_api/runtime/src/__init__.py index d50a93a9..5221bec5 100644 --- a/raster_api/runtime/src/__init__.py +++ b/raster_api/runtime/src/__init__.py @@ -1 +1 @@ -"""delta.raster_api""" +"""veda.raster_api""" diff --git a/raster_api/runtime/src/app.py b/raster_api/runtime/src/app.py index 495b0af0..f3b9f945 100644 --- a/raster_api/runtime/src/app.py +++ b/raster_api/runtime/src/app.py @@ -7,7 +7,7 @@ from src.config import ApiSettings from src.datasetparams import DatasetParams from src.factory import MosaicTilerFactory, MultiBaseTilerFactory -from src.version import __version__ as delta_raster_version +from src.version import __version__ as veda_raster_version from fastapi import APIRouter, Depends, FastAPI, Query from starlette.middleware.cors import CORSMiddleware @@ -38,7 +38,7 @@ else: optional_headers = [] -app = FastAPI(title=settings.name, version=delta_raster_version) +app = FastAPI(title=settings.name, version=veda_raster_version) # router to be applied to all titiler route factories (improves logs with FastAPI context) router = APIRouter(route_class=LoggerRouteHandler) add_exception_handlers(app, DEFAULT_STATUS_CODES) diff --git a/raster_api/runtime/src/config.py b/raster_api/runtime/src/config.py index fa9b89d8..28234882 100644 --- a/raster_api/runtime/src/config.py +++ b/raster_api/runtime/src/config.py @@ -48,7 +48,7 @@ def get_role_credentials(role_arn: str): class ApiSettings(BaseSettings): """API settings""" - name: str = "delta-raster" + name: str = "veda-raster" cors_origins: str = "*" cachecontrol: str = "public, max-age=3600" debug: bool = False @@ -113,4 +113,4 @@ class Config: """model config""" env_file = ".env" - env_prefix = "DELTA_RASTER_" + env_prefix = "VEDA_RASTER_" diff --git a/raster_api/runtime/src/dependencies.py b/raster_api/runtime/src/dependencies.py index 1ef8f60a..c4914138 100644 --- a/raster_api/runtime/src/dependencies.py +++ b/raster_api/runtime/src/dependencies.py @@ -1,4 +1,4 @@ -"""delta.raster.dependencies.""" +"""veda.raster.dependencies.""" import json from base64 import b64decode diff --git a/setup.py b/setup.py index 301d1db4..264d779a 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,4 @@ -"""Setup delta-backend.""" +"""Setup veda-backend.""" from setuptools import find_packages, setup @@ -26,7 +26,7 @@ setup( - name="delta-backend", + name="veda-backend", version="0.6.2", description="", long_description=long_description, @@ -42,10 +42,10 @@ keywords="", author="Development Seed", author_email="info@developmentseed.org", - url="https://github.com/NASA-IMPACT/delta-backend", + url="https://github.com/NASA-IMPACT/veda-backend", license="MIT", packages=find_packages(exclude=["ez_setup", "examples", "tests"]), - package_data={"delta-backend": ["templates/*.html", "templates/*.xml"]}, + package_data={"veda-backend": ["templates/*.html", "templates/*.xml"]}, include_package_data=True, zip_safe=False, install_requires=[], diff --git a/stac_api/infrastructure/config.py b/stac_api/infrastructure/config.py index cacf797d..7bbd4dde 100644 --- a/stac_api/infrastructure/config.py +++ b/stac_api/infrastructure/config.py @@ -4,7 +4,7 @@ from pydantic import BaseSettings, Field -class deltaSTACSettings(BaseSettings): +class vedaSTACSettings(BaseSettings): """Application settings""" env: Dict = {} @@ -22,7 +22,7 @@ class Config: """model config""" env_file = ".env" - env_prefix = "DELTA_STAC_" + env_prefix = "VEDA_STAC_" -delta_stac_settings = deltaSTACSettings() +veda_stac_settings = vedaSTACSettings() diff --git a/stac_api/infrastructure/construct.py b/stac_api/infrastructure/construct.py index c6982025..4b9d45f5 100644 --- a/stac_api/infrastructure/construct.py +++ b/stac_api/infrastructure/construct.py @@ -13,7 +13,7 @@ ) from constructs import Construct -from .config import delta_stac_settings +from .config import veda_stac_settings class StacApiLambdaConstruct(Construct): @@ -47,12 +47,12 @@ def __init__( ), vpc=vpc, allow_public_subnet=True, - memory_size=delta_stac_settings.memory, - timeout=Duration.seconds(delta_stac_settings.timeout), + memory_size=veda_stac_settings.memory, + timeout=Duration.seconds(veda_stac_settings.timeout), environment={ "DB_MIN_CONN_SIZE": "0", "DB_MAX_CONN_SIZE": "1", - **{k.upper(): v for k, v in delta_stac_settings.env.items()}, + **{k.upper(): v for k, v in veda_stac_settings.env.items()}, }, log_retention=aws_logs.RetentionDays.ONE_WEEK, tracing=aws_lambda.Tracing.ACTIVE, @@ -67,7 +67,7 @@ def __init__( lambda_function.add_environment("TITILER_ENDPOINT", raster_api.raster_api.url) lambda_function.add_environment( - "DELTA_STAC_PGSTAC_SECRET_ARN", database.pgstac.secret.secret_full_arn + "VEDA_STAC_PGSTAC_SECRET_ARN", database.pgstac.secret.secret_full_arn ) stac_api_integration = ( diff --git a/stac_api/runtime/README.md b/stac_api/runtime/README.md index 006e8b14..a12aa1cb 100644 --- a/stac_api/runtime/README.md +++ b/stac_api/runtime/README.md @@ -1 +1 @@ -## delta.stac_api +## veda.stac_api diff --git a/stac_api/runtime/setup.py b/stac_api/runtime/setup.py index 13b81c91..04399fc8 100644 --- a/stac_api/runtime/setup.py +++ b/stac_api/runtime/setup.py @@ -26,11 +26,11 @@ setup( - name="delta.stac_api", + name="veda.stac_api", description="", python_requires=">=3.7", packages=find_namespace_packages(exclude=["tests*"]), - package_data={"delta": ["stac/templates/*.html"]}, + package_data={"veda": ["stac/templates/*.html"]}, include_package_data=True, zip_safe=False, install_requires=inst_reqs, diff --git a/stac_api/runtime/src/__init__.py b/stac_api/runtime/src/__init__.py index a2c0fac2..b6473049 100644 --- a/stac_api/runtime/src/__init__.py +++ b/stac_api/runtime/src/__init__.py @@ -1 +1 @@ -"""delta.stac_api""" +"""veda.stac_api""" diff --git a/stac_api/runtime/src/config.py b/stac_api/runtime/src/config.py index 32ded30c..b8386993 100644 --- a/stac_api/runtime/src/config.py +++ b/stac_api/runtime/src/config.py @@ -49,7 +49,7 @@ def get_secret_dict(secret_name: str): class _ApiSettings(pydantic.BaseSettings): """API settings""" - name: str = "delta-backend-stac" + name: str = "veda-stac" cors_origins: str = "*" cachecontrol: str = "public, max-age=3600" debug: bool = False @@ -82,7 +82,7 @@ class Config: """model config""" env_file = ".env" - env_prefix = "DELTA_STAC_" + env_prefix = "VEDA_STAC_" @lru_cache() diff --git a/standalone_base_infrastructure/standalone_app.py b/standalone_base_infrastructure/standalone_app.py index b48f5128..46a33934 100644 --- a/standalone_base_infrastructure/standalone_app.py +++ b/standalone_base_infrastructure/standalone_app.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -""" CDK Configuration for the delta-backend stack.""" +""" CDK Configuration for base deployment infrastructure fo the veda-backend stack.""" from aws_cdk import App, Stack from constructs import Construct diff --git a/support_scripts/README.md b/support_scripts/README.md index 15e426ce..67c0ed70 100644 --- a/support_scripts/README.md +++ b/support_scripts/README.md @@ -9,8 +9,8 @@ This cli script will rotate the postgres connection password in a specified AWS ### Required input parameters To use the script, the following AWS resource names are required -- **`--admin`** the AWS secret containing the *admin* postgres connection info. This role will be used to update a pgstac user role. This secret will have a description `Generated by the CDK for stack: delta-backend-` -- **`--pgstac`** the aws secret containing the pgstac user role to be updated. This secret will have a description `Pgstac database bootsrapped by delta-backend- stack` +- **`--admin`** the AWS secret containing the *admin* postgres connection info. This role will be used to update a pgstac user role. This secret will have a description `Generated by the CDK for stack: veda-backend-` +- **`--pgstac`** the aws secret containing the pgstac user role to be updated. This secret will have a description `Pgstac database bootsrapped by veda-backend- stack` - **`--stac`** and **`--raster`** the resource names of the STAC and Raster lambdas that are using the pgstac connection secret. ### Optional dry run diff --git a/support_scripts/rotate_pgstac_pasword.py b/support_scripts/rotate_pgstac_pasword.py index a2378500..517f6cd2 100644 --- a/support_scripts/rotate_pgstac_pasword.py +++ b/support_scripts/rotate_pgstac_pasword.py @@ -194,7 +194,7 @@ def force_update_lambda( admin_dsn = get_dsn_string(admin_secret_dict) # Get pgstac user secret to update -print(f"Loading pgstac delta user credentials from secret={args.pgstac_secret_name}") +print(f"Loading pgstac veda user credentials from secret={args.pgstac_secret_name}") pgstac_secret_dict = get_secret_dict( args.pgstac_secret_name, profile_name=args.profile_name ) From 57618334e41aba55a51a3ca6b7fc625c7314bf61 Mon Sep 17 00:00:00 2001 From: anayeaye Date: Mon, 12 Dec 2022 13:31:48 -0700 Subject: [PATCH 2/3] fix enable context in database construct to unblock deployment --- database/runtime/handler.py | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/database/runtime/handler.py b/database/runtime/handler.py index c285c733..b27fbcdd 100644 --- a/database/runtime/handler.py +++ b/database/runtime/handler.py @@ -122,17 +122,23 @@ def create_permissions(cursor, db_name: str, username: str) -> None: "GRANT pgstac_read TO {username};" "GRANT pgstac_ingest TO {username};" "GRANT pgstac_admin TO {username};" - "ALTER ROLE {username} SET SEARCH_PATH to pgstac, public;" - "ALTER ROLE {username} SET pgstac.context TO 'auto';" - "ALTER ROLE {username} SET pgstac.context_estimated_count TO '100000';" - "ALTER ROLE {username} SET pgstac.context_estimated_cost TO '100000';" - "ALTER ROLE {username} SET pgstac.context_stats_ttl TO '1 day';" ).format( db_name=sql.Identifier(db_name), username=sql.Identifier(username), ) ) +def enable_context(cursor) -> None: + """Enable context extension for actual and estimated matches in item search and associated optimizations.""" + cursor.execute(sql.SQL( + "INSERT INTO pgstac.pgstac_settings (name, value) " + " VALUES " + " ('context', 'auto')," + " ('context_estimated_count', '100000')," + " ('context_estimated_cost', '100000')," + " ('context_stats_ttl', '1 day')" + " ON CONFLICT ON CONSTRAINT pgstac_settings_pkey DO UPDATE SET value = excluded.value;" + )) def register_extensions(cursor) -> None: """Add PostGIS extension.""" @@ -351,6 +357,13 @@ def handler(event, context): username=user_params["username"], ) + with psycopg.connect(stac_db_conninfo, autocommit=True) as conn: + with conn.cursor() as cur: + print("Enabling and configuring item search context in pgstac_settings...") + enable_context( + cursor=cur, + ) + print("Adding mosaic index...") with psycopg.connect( stac_db_admin_dsn, From 53648c69c44a886f771c84e09a4ef89de19e963a Mon Sep 17 00:00:00 2001 From: anayeaye Date: Mon, 12 Dec 2022 13:34:07 -0700 Subject: [PATCH 3/3] lint --- database/runtime/handler.py | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/database/runtime/handler.py b/database/runtime/handler.py index b27fbcdd..52ea7c93 100644 --- a/database/runtime/handler.py +++ b/database/runtime/handler.py @@ -128,17 +128,21 @@ def create_permissions(cursor, db_name: str, username: str) -> None: ) ) + def enable_context(cursor) -> None: """Enable context extension for actual and estimated matches in item search and associated optimizations.""" - cursor.execute(sql.SQL( - "INSERT INTO pgstac.pgstac_settings (name, value) " - " VALUES " - " ('context', 'auto')," - " ('context_estimated_count', '100000')," - " ('context_estimated_cost', '100000')," - " ('context_stats_ttl', '1 day')" - " ON CONFLICT ON CONSTRAINT pgstac_settings_pkey DO UPDATE SET value = excluded.value;" - )) + cursor.execute( + sql.SQL( + "INSERT INTO pgstac.pgstac_settings (name, value) " + " VALUES " + " ('context', 'auto')," + " ('context_estimated_count', '100000')," + " ('context_estimated_cost', '100000')," + " ('context_stats_ttl', '1 day')" + " ON CONFLICT ON CONSTRAINT pgstac_settings_pkey DO UPDATE SET value = excluded.value;" + ) + ) + def register_extensions(cursor) -> None: """Add PostGIS extension.""" @@ -359,7 +363,9 @@ def handler(event, context): with psycopg.connect(stac_db_conninfo, autocommit=True) as conn: with conn.cursor() as cur: - print("Enabling and configuring item search context in pgstac_settings...") + print( + "Enabling and configuring item search context in pgstac_settings..." + ) enable_context( cursor=cur, )