Skip to content

Commit

Permalink
Merge pull request #134 from NASA-IMPACT/feature/delta-to-veda
Browse files Browse the repository at this point in the history
Rename variables: delta->veda
  • Loading branch information
anayeaye authored Dec 12, 2022
2 parents 640945c + 53648c6 commit 3592839
Show file tree
Hide file tree
Showing 31 changed files with 202 additions and 183 deletions.
20 changes: 10 additions & 10 deletions .example.env
Original file line number Diff line number Diff line change
Expand Up @@ -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]
2 changes: 1 addition & 1 deletion .github/workflows/tests/test_raster.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""test delta-backend.raster."""
"""test veda-backend.raster."""

import httpx

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests/test_stac.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""test Delta-backend STAC."""
"""test veda-backend STAC."""

import httpx

Expand Down
38 changes: 19 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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 `<app-name>-backend/<stage>-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 `<app-name>-backend/<stage>-env`, for example `veda-backend/dev-env`.

### Fetch environment variables using AWS CLI

Expand All @@ -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

Expand All @@ -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://<account number>.signin.aws.amazon.com/console the status of the CloudFormation stack can be viewed here: https://<aws-region>.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

Expand Down Expand Up @@ -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.
50 changes: 25 additions & 25 deletions app.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -14,54 +14,54 @@
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,
domain_name=domain.raster_domain_name,
)

stac_api = StacApiLambdaConstruct(
delta_stack,
veda_stack,
"stac-api",
vpc=vpc.vpc,
database=database,
Expand All @@ -70,25 +70,25 @@ 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,
domain_name=alt_domain.raster_domain_name,
)

alt_stac_api = StacApiLambdaConstruct(
delta_stack,
veda_stack,
"alt-stac-api",
vpc=vpc.vpc,
database=database,
Expand All @@ -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():
Expand Down
16 changes: 8 additions & 8 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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:
Expand All @@ -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,
]
)

Expand All @@ -77,4 +77,4 @@ class Config:
env_file = ".env"


delta_app_settings = deltaAppSettings()
veda_app_settings = vedaAppSettings()
12 changes: 6 additions & 6 deletions database/infrastructure/config.py
Original file line number Diff line number Diff line change
@@ -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(
Expand All @@ -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(
Expand All @@ -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,
Expand Down Expand Up @@ -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()
Loading

0 comments on commit 3592839

Please sign in to comment.