Skip to content
This repository has been archived by the owner on Jun 18, 2024. It is now read-only.

Fetch upstream changes #51

Merged
merged 178 commits into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
178 commits
Select commit Hold shift + click to select a range
fc56b26
Merge pull request #119 from NASA-IMPACT/develop
anayeaye Oct 13, 2022
115a73a
Merge pull request #145 from NASA-IMPACT/develop
smohiudd Jan 17, 2023
34f3091
Fix mangum db connection pool
ividito Jan 13, 2023
448158c
lint
ividito Jan 18, 2023
f42264e
Point README to veda-docs (#171)
jsignell Apr 20, 2023
1cff316
Upgrade titiler and titiler-pgstac
ividito Jan 25, 2023
a6a6c14
Fix br/gzip header test
ividito Jan 30, 2023
5619e86
Remove factory (it's included in new titiler-pgstac version)
ividito Mar 28, 2023
3646036
Remove pin on cramjam
ividito Mar 28, 2023
1988752
Load test data in container (actions not updated)
ividito Mar 28, 2023
47d22ac
fix actions tests
ividito Mar 28, 2023
02800f1
adjust container strategy
ividito Mar 28, 2023
91b50a9
actions connections fix
ividito Mar 29, 2023
d93c9ed
remove -it flag (it broke actions)
ividito Mar 29, 2023
12380b2
re-enable lint, propagate test changes to other actions
ividito Mar 29, 2023
7e111c1
docker-compose -> docker compose
ividito Mar 30, 2023
36c34ee
Fix template import
ividito Apr 18, 2023
55c305a
include private subnet config
smohiudd Apr 25, 2023
6299c4f
fix subnet type
smohiudd Apr 25, 2023
04cf6e8
format changes
smohiudd Apr 26, 2023
b0ad279
pub accessible default true
smohiudd Apr 28, 2023
db842fa
remove publicly accessible variable
smohiudd May 2, 2023
8186576
Merge pull request #173 from NASA-IMPACT/rds-private-subnet
smohiudd May 2, 2023
3d69ff8
Add sql connection and execution abstraction
moradology May 15, 2023
2dd4b2d
Add sql logic to fix projection extension types
moradology May 15, 2023
0353c93
add script to delete null stac_extensions
moradology May 16, 2023
864118b
Lint and move sql command scripts to support_scripts dir
moradology May 16, 2023
d5fb29a
Use pythonic naming conventions
moradology May 17, 2023
74ad08a
pgstac readme change
smohiudd May 17, 2023
25312b7
Merge pull request #180 from NASA-IMPACT/pgstac-upgrade
smohiudd May 22, 2023
9d208cb
pin to urllib3<2
smohiudd May 23, 2023
be246ee
pin urllib3 in test
smohiudd May 23, 2023
29f9d8c
format
smohiudd May 23, 2023
93cb4d8
revert
smohiudd May 23, 2023
01cdd3c
pin httpx
smohiudd May 23, 2023
ebc5161
revert
smohiudd May 23, 2023
6dbf0b3
docker compose pgstac version
smohiudd May 23, 2023
d595aed
pre-deploy action fix
ividito May 23, 2023
3fd852f
Merge pull request #182 from NASA-IMPACT/urllib3-fix
smohiudd May 23, 2023
33d61f3
RDS Proxy initial implementation
ividito May 22, 2023
dd07c26
proxy secret + urlllib fix
ividito May 23, 2023
c407045
use pgstac 0.7.4
smohiudd May 23, 2023
298ba11
Merge pull request #183 from NASA-IMPACT/urllib3-fix
smohiudd May 24, 2023
656ba1c
Merge pull request #175 from NASA-IMPACT/feature/sql-scripts
moradology Jun 1, 2023
5d74fed
use titiler custom JSONResponse to handle NaN values
vincentsarago Jun 12, 2023
01a7814
Merge pull request #188 from NASA-IMPACT/fixJSONresponseForValidate
anayeaye Jun 12, 2023
8bd4670
change db search path
smohiudd Jun 27, 2023
f7cc17c
Merge pull request #190 from NASA-IMPACT/fix/db-search-path
smohiudd Jun 27, 2023
6db8330
hacky fix
Jul 10, 2023
f816599
try exporting os env vars
Jul 10, 2023
a90a483
export os env vars
Jul 10, 2023
c4cebb8
lint
anayeaye Jul 10, 2023
42d3dd8
comment
anayeaye Jul 10, 2023
f2cae04
move to APISettings check
Jul 11, 2023
41aa5a6
black changes
Jul 11, 2023
2fae434
Merge pull request #194 from NASA-IMPACT/issue-192
ranchodeluxe Jul 11, 2023
c141705
hide route
anayeaye Jul 13, 2023
a2a6142
Merge pull request #196 from NASA-IMPACT/feature/hide-endpoint
anayeaye Jul 13, 2023
5ffb1b2
Pin pydantic for now
ividito Jul 14, 2023
37ee00a
put raster assume role config in lambda construct
anayeaye Jul 17, 2023
933ff7c
pass lambda env variable bool as string
anayeaye Jul 17, 2023
22bb657
Merge pull request #200 from NASA-IMPACT/fix/put-exp-session-variable…
anayeaye Jul 17, 2023
e0f6572
Merge pull request #178 from NASA-IMPACT/develop
anayeaye Jul 17, 2023
f2af77e
NAT SG rules
Jul 25, 2023
9764d82
order of operation
Jul 25, 2023
02bdbf5
remove implicity SGs
Jul 25, 2023
52b4a95
black formatted
Jul 25, 2023
deab639
Merge pull request #202 from NASA-IMPACT/bug/nat_sg_inbound_cidr
ranchodeluxe Jul 26, 2023
9235f52
fix invalid string in rule description
anayeaye Jul 26, 2023
651964d
Merge pull request #205 from NASA-IMPACT/bug/nat_sg_inbound_cidr_p2
anayeaye Jul 31, 2023
d897641
updates to deployment docs in readme
anayeaye Aug 14, 2023
9ceb8a7
update pgstac version in docker compose
anayeaye Aug 14, 2023
7ef9155
use max/end datetime in periodic collection datetime summary
anayeaye Aug 14, 2023
75b91b1
correct table name typo
anayeaye Aug 14, 2023
71730ac
Merge pull request #211 from NASA-IMPACT/fix/collection-extents-and-s…
anayeaye Aug 15, 2023
a885d0f
Merge pull request #210 from NASA-IMPACT/feature/update-deployment-docs
anayeaye Aug 15, 2023
f93c2e2
Merge pull request #212 from NASA-IMPACT/develop
anayeaye Aug 15, 2023
73aa15c
use NAT Gateway instead of EC2 Instance as NAT
Aug 23, 2023
a568c03
aws_ec2 mistake
Aug 23, 2023
4e51d31
use aws_ec2.SubnetType.PRIVATE_WITH_EGRESS
Aug 23, 2023
1b55f03
add back in NAT count
Aug 23, 2023
f13a5a5
add rds subnet group manual removal step to instructions for destroyi…
anayeaye Aug 23, 2023
700edfe
Enable tilematrixsets
moradology Aug 23, 2023
d6601ed
Merge pull request #213 from NASA-IMPACT/feature/nat_gateway_service
ranchodeluxe Aug 23, 2023
a21ad1f
Merge pull request #217 from NASA-IMPACT/feature/enable-tilematrixsets
moradology Aug 23, 2023
b875238
feat(database): RDS Configurations (#218)
jjfrench Aug 24, 2023
396c057
raster path prefix
smohiudd Aug 25, 2023
818352d
stac path prefix
smohiudd Aug 25, 2023
b53d8f0
format
smohiudd Aug 25, 2023
1425de6
config changes
smohiudd Aug 30, 2023
3a26c1c
format
smohiudd Aug 31, 2023
972725b
Revert "format"
smohiudd Sep 1, 2023
8e8df13
Revert "config changes"
smohiudd Sep 1, 2023
b9dceef
Merge pull request #219 from NASA-IMPACT/feature/path-prefix
smohiudd Sep 6, 2023
265dbd5
feat: add configuration and github actions for python-semantic-release
anayeaye Sep 7, 2023
b9351ba
feat: lint conventional pr
anayeaye Sep 7, 2023
15e6eee
ci: cdk deploy should not require approval in github actions workflow
anayeaye Sep 7, 2023
437e815
docs: add contributing.md
anayeaye Sep 11, 2023
9d0dec0
chore(ci): fix typo
anayeaye Sep 11, 2023
d8a010b
chore: explain versioning init choice
anayeaye Sep 11, 2023
87e2678
chore: expalin automated version in setup.py
anayeaye Sep 11, 2023
edba7fb
chore: typo
anayeaye Sep 11, 2023
d5f1b3b
docs: typos and improvements in contributing docs
anayeaye Sep 11, 2023
ae78cf9
chore: merge pr suggestions
anayeaye Sep 11, 2023
9d7588c
docs: typos in contributing
anayeaye Sep 12, 2023
e783a5a
Merge pull request #223 from NASA-IMPACT/feature/semantic-releases
anayeaye Sep 12, 2023
163a89c
ci: handle semantic version releases with tags only
anayeaye Sep 12, 2023
2b292be
chore: add exclude commit patterns from release changelog
anayeaye Sep 14, 2023
0c818f9
fix: handle semantic version releases with tags only (#225)
anayeaye Sep 19, 2023
9aa3311
docs: improve instructions for destroying a veda-backend stack (#216)
anayeaye Sep 19, 2023
d653734
cloudfront in veda backend
smohiudd Sep 25, 2023
30223d9
format
smohiudd Sep 25, 2023
7db6adc
fix: if provided, apply permissions boundary to all roles created wit…
anayeaye Sep 28, 2023
e4b02a5
fix: apply permissions boundary (#231)
anayeaye Oct 4, 2023
41e011d
mypy, pydocstyle fixes
smohiudd Sep 25, 2023
dccaf49
include apigateway parameter mapping
smohiudd Oct 5, 2023
30985be
remove unused import
smohiudd Oct 5, 2023
5b02663
update readme
smohiudd Oct 5, 2023
1e222d8
remove unused config
smohiudd Oct 5, 2023
7b54953
docs: s/veda-data-pipelines/veda-data-airflow/
gadomski Oct 10, 2023
8cf092c
include parameter mapping in raster api
smohiudd Oct 10, 2023
b63966a
ci: branch specific pre-deploy check on pull request action
anayeaye Oct 11, 2023
f41c7fb
ci: pre-deploy test against dev stack by default
anayeaye Oct 11, 2023
a7d7ba7
fix github var name in action
anayeaye Oct 11, 2023
60e894b
typo
anayeaye Oct 11, 2023
7924a6d
include conditional param mapping
smohiudd Oct 12, 2023
dd1d675
change param mapping kwargs
smohiudd Oct 12, 2023
8965651
feat: add configuration for deploying a cloudfront distribution for t…
smohiudd Oct 12, 2023
496e99f
ci: branch specific pre-deploy check on pull request action (#236)
anayeaye Oct 12, 2023
f32f152
fix cloudfront subdomain
smohiudd Oct 12, 2023
f6f7138
incude missing argument
smohiudd Oct 12, 2023
31ce1b4
formatting
smohiudd Oct 12, 2023
f463791
fix: include stage subdomain in cloudfront distribution (#237)
smohiudd Oct 13, 2023
1bf6078
feat(raster)!: update titiler-pgstac from 0.2.3 to 0.8.0
vincentsarago Oct 16, 2023
d177f15
add dependencies
vincentsarago Oct 16, 2023
fbc7cc7
add tests deps
vincentsarago Oct 16, 2023
0a885a2
fix tests
vincentsarago Oct 16, 2023
e748c83
:facepalm:
vincentsarago Oct 16, 2023
0dea328
update handler
vincentsarago Oct 17, 2023
494a8de
pin pydantic to 1.* for cdk deployment
vincentsarago Oct 17, 2023
441c543
fix deps
vincentsarago Oct 17, 2023
7f0cbbc
feat(raster)!: update titiler-pgstac from 0.2.3 to 0.8.0 (#239)
anayeaye Oct 17, 2023
c6cbccd
fix(raster) use root path for prefixing and add to gateway base url i…
anayeaye Oct 24, 2023
dce8046
fix(stac) use root path for prefixing urls
anayeaye Oct 24, 2023
7ad2229
root path in fastapi app
anayeaye Oct 24, 2023
ee47d9b
updates to for using a proxy
anayeaye Oct 27, 2023
c1d0330
lint
anayeaye Oct 27, 2023
12b9cbd
only add additional servers to fast api if root path in config
anayeaye Oct 27, 2023
4136ad5
root path setting is optional
anayeaye Oct 30, 2023
40e4360
cleanup
anayeaye Oct 30, 2023
9620979
cleanup
anayeaye Oct 30, 2023
522b608
do not configure alias for shared subdomain
anayeaye Oct 31, 2023
ddef808
pr review cleanup
anayeaye Oct 31, 2023
7d13aa7
fastapi additional servers not needed with apigw base path=app.root_path
anayeaye Nov 1, 2023
dd00f5a
fix(api)!: use root path for prefixing (#241)
anayeaye Nov 1, 2023
ce9c7e8
add custom colormap for EPA dataset
vincentsarago Nov 2, 2023
4d6d2ac
Update raster_api/runtime/src/cmap_data/README.md
vincentsarago Nov 6, 2023
72d55d6
rename cmap
vincentsarago Nov 6, 2023
d3bf6ff
feat(raster): add custom colormap for EPA dataset (#243)
anayeaye Nov 7, 2023
9edc296
fix(apis)!: overwrite host in api integration if custom host provided
anayeaye Nov 8, 2023
6c66f06
fix(apis)!: overwrite host in api integration if custom host provided…
anayeaye Nov 8, 2023
ab10741
fix(routes)!: ingest api root path is /api/publish
anayeaye Nov 8, 2023
99f58f3
change ingestor api cf behavior
smohiudd Nov 9, 2023
65f4af6
format
smohiudd Nov 9, 2023
c6bc465
fix(domain)! only create custom api subdomains when configured
anayeaye Nov 9, 2023
1747fce
improve config descriptions
anayeaye Nov 9, 2023
93773cf
Merge branch 'fix/configure-overwrite-host' of https://github.com/NAS…
anayeaye Nov 9, 2023
6baf8ae
typo
anayeaye Nov 9, 2023
c4be52f
improve domain config docs
anayeaye Nov 9, 2023
6f73459
account for custom staged url of veda-stac-ingestor
anayeaye Nov 9, 2023
7072ca2
fix(apis)!: overwrite api host when provided in config (#245)
anayeaye Nov 9, 2023
d1d009b
feat!: bulk upstream changes (171 commits)
anayeaye Nov 9, 2023
5dccd30
do not run lint conventional pr
anayeaye Nov 9, 2023
bda79bf
merge duplicate corrected
anayeaye Nov 9, 2023
7e7f5b8
lint
anayeaye Nov 9, 2023
38aedc7
merge mismatched rds config naming
anayeaye Nov 9, 2023
3367010
merge inconsistencies
anayeaye Nov 9, 2023
5e57e0f
merge inconsistencies
anayeaye Nov 10, 2023
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
15 changes: 11 additions & 4 deletions .example.env
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,16 @@ VEDA_DOMAIN_ALT_HOSTED_ZONE_ID=[OPTIONAL SECOND HOSTED ZONE]
VEDA_DOMAIN_ALT_HOSTED_ZONE_NAME=[OPTIONAL SECOND DOMAIN]

VEDA_RASTER_ENABLE_MOSAIC_SEARCH=TRUE
VEDA_RASTER_DATA_ACCESS_ROLE_ARN=[OPTIONAL ARN OF IAM ROLE TO BE ASSUMED BY RASTER API]
VEDA_RASTER_DATA_ACCESS_ROLE_ARN=[OPTIONAL ARN OF IAM ROLE TO BE ASSUMED BY RASTER API]
VEDA_RASTER_EXPORT_ASSUME_ROLE_CREDS_AS_ENVS=False

VEDA_RASTER_PATH_PREFIX=[OPTIONAL PATH PREFIX TO ADD TO TITILER ENDPOINTS]
VEDA_STAC_PATH_PREFIX=[OPTIONAL PATH PREFIX TO ADD TO TITILER ENDPOINTS]
VEDA_DB_PUBLICLY_ACCESSIBLE=TRUE

VEDA_RASTER_ROOT_PATH=
VEDA_STAC_ROOT_PATH=

VEDA_HOST=[OPTIONAL HOST/DOMAIN_NAME TO PROPAGATE TO STAC AND RASTER APIS]
STAC_BROWSER_BUCKET=
STAC_URL=
CERT_ARN=
VEDA_CLOUDFRONT=
VEDA_CUSTOM_HOST=
4 changes: 3 additions & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ jobs:
with:
python-version: '3.9'


- uses: actions/cache@v3
with:
path: ${{ env.pythonLocation }}
Expand All @@ -69,7 +70,7 @@ jobs:
- name: Install python dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -e .[dev,deploy,test]
python -m pip install -e .[dev,deploy,test]

- name: Launch services
run: AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY=${{secrets.AWS_SECRET_ACCESS_KEY}} docker compose up --build -d
Expand All @@ -82,6 +83,7 @@ jobs:
run: sleep 10s
shell: bash


- name: Integrations tests
run: python -m pytest .github/workflows/tests/ -vv -s

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/tests/test_raster.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ def test_mosaic_api():
assert list(resp.json()[0]) == ["id", "bbox", "assets", "collection"]
assert resp.json()[0]["id"] == "20200307aC0853900w361030"

resp = httpx.get(f"{raster_endpoint}/mosaic/{searchid}/15/8589/12849/assets")
resp = httpx.get(f"{raster_endpoint}/mosaic/{searchid}/tiles/15/8589/12849/assets")
assert resp.status_code == 200
assert len(resp.json()) == 1
assert list(resp.json()[0]) == ["id", "bbox", "assets", "collection"]
assert resp.json()[0]["id"] == "20200307aC0853900w361030"

z, x, y = 15, 8589, 12849
resp = httpx.get(
f"{raster_endpoint}/mosaic/tiles/{searchid}/{z}/{x}/{y}",
f"{raster_endpoint}/mosaic/{searchid}/tiles/{z}/{x}/{y}",
params={"assets": "cog"},
headers={"Accept-Encoding": "br, gzip"},
timeout=10.0,
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ repos:
language_version: python

- repo: https://github.com/PyCQA/flake8
rev: 3.8.3
rev: 6.1.0
hooks:
- id: flake8
language_version: python
Expand Down
4 changes: 2 additions & 2 deletions .readme/veda-backend.drawio.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
113 changes: 111 additions & 2 deletions .readme/veda-backend.drawio.xml

Large diffs are not rendered by default.

45 changes: 37 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,42 @@ To retrieve the variables for a stage that has been previously deployed, the sec
| `VEDA_DB_PGSTAC_VERSION` | **REQUIRED** version of PgStac database, i.e. 0.7.9 |
| `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 |
> **Note** See [Advanced Configuration](docs/advanced_configuration.md) for details about custom configuration options.

### Advanced configuration
The constructs and applications in this project are configured using pydantic. The settings are defined in config.py files stored alongside the associated construct or application--for example the settings for the RDS PostgreSQL construct are defined in database/infrastructure/config.py. For custom configuration, use environment variables to override the pydantic defaults.

| Construct | Env Prefix | Configuration |
| --- | --- | --- |
| Database | `VEDA_DB` | [database/infrastructure/config.py](database/infrastructure/config.py) |
| Domain | `VEDA_DOMAIN` | [domain/infrastructure/config.py](domain/infrastructure/config.py) |
| Network | `N/A` | [network/infrastructure/config.py](network/infrastructure/config.py) |
| Raster API (TiTiler) | `VEDA_RASTER` | [raster_api/infrastructure/config.py](raster_-_api/infrastructure/config.py) |
| STAC API | `VEDA` | [stac_api/infrastructure/config.py](stac_api/infrastructure/config.py) |
| Routes | `VEDA` | [routes/infrastructure/config.py](routes/infrastructure/config.py) |

### Deploying to the cloud

#### Install pre-requisites
#### Install deployment pre-requisites
- [Node](https://nodejs.org/)
- [NVM](https://github.com/nvm-sh/nvm#node-version-manager---)
- [jq](https://jqlang.github.io/jq/) (used for exporting environment variable secrets to `.env` in [scripts/sync-env-local.sh](/scripts/sync-env-local.sh))

These can be installed with [homebrew](https://brew.sh/) on MacOS
```
brew install node
brew install nvm
brew install jq
```

#### Virtual environment example
```
python3 -m venv .venv
source .venv/bin/activate
```

#### Install requirements
```bash
nvm install 17
nvm use 17
node --version
nvm use --lts
npm install --location=global aws-cdk
python3 -m pip install --upgrade pip
python3 -m pip install -e ".[dev,deploy,test]"
Expand All @@ -72,8 +98,9 @@ cdk deploy
If this is a development stack that is safe to delete, you can delete the stack in CloudFormation console or via `cdk destroy`, however, the additional manual steps were required to completely delete the stack resources:

1. You will need to disable deletion protection of the RDS database and delete the database.
2. Detach the Internet Gateway (IGW) from the VPC and delete it.
3. If this stack created a new VPC, delete the VPC (this should delete a subnet and security group too).
2. Identify and delete the RDS subnet group associated with the RDS database you just deleted (it will not be automatically removed because of the RDS deletion protection in place when the group was created).
3. If this stack created a new VPC, detach the Internet Gateway (IGW) from the VPC and delete it.
4. If this stack created a new VPC, delete the VPC (this should delete a subnet and security group too).

## Custom deployments

Expand All @@ -98,7 +125,7 @@ docker compose down

> **Warning** PgSTAC records should be loaded in the database using [pypgstac](https://github.com/stac-utils/pgstac#pypgstac) for proper indexing and partitioning.

The VEDA ecosystem includes tools specifially created for loading PgSTAC records and optimizing data assets. The [veda-data-pipelines](https://github.com/NASA-IMPACT/veda-data-pipelines) project provides examples of cloud pipelines that transform data to cloud optimized formats, generate STAC metadata, and submit records for publication to the veda-backend database using the [veda-stac-ingestor](https://github.com/NASA-IMPACT/veda-stac-ingestor).
The VEDA ecosystem includes tools specifially created for loading PgSTAC records and optimizing data assets. The [veda-data-airflow](https://github.com/NASA-IMPACT/veda-data-airflow) project provides examples of cloud pipelines that transform data to cloud optimized formats, generate STAC metadata, and submit records for publication to the veda-backend database using the [veda-stac-ingestor](https://github.com/NASA-IMPACT/veda-stac-ingestor).

## Support scripts
Support scripts are provided for manual system operations.
Expand All @@ -118,6 +145,7 @@ Support scripts are provided for manual system operations.

## VEDA usage examples

### [VEDA documentation](https://nasa-impact.github.io/veda-docs)
### [VEDA documentation](https://nasa-impact.github.io/veda-docs)

### [VEDA dashboard](https://www.earthdata.nasa.gov/dashboard)
Expand All @@ -129,3 +157,4 @@ Radiant Earth's [stac-browser](https://github.com/radiantearth/stac-browser) is

# License
This project is licensed under **Apache 2**, see the [LICENSE](LICENSE) file for more details.

20 changes: 17 additions & 3 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from domain.infrastructure.construct import DomainConstruct
from network.infrastructure.construct import VpcConstruct
from raster_api.infrastructure.construct import RasterApiLambdaConstruct
from routes.infrastructure.construct import CloudfrontDistributionConstruct
from stac_api.infrastructure.construct import StacApiLambdaConstruct

app = App()
Expand All @@ -24,7 +25,7 @@ def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
if veda_app_settings.permissions_boundary_policy_name:
permission_boundary_policy = aws_iam.ManagedPolicy.from_managed_policy_name(
self,
"permission-boundary",
"permissions-boundary",
veda_app_settings.permissions_boundary_policy_name,
)
aws_iam.PermissionsBoundary.of(self).apply(permission_boundary_policy)
Expand Down Expand Up @@ -59,18 +60,29 @@ def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
raster_api = RasterApiLambdaConstruct(
veda_stack,
"raster-api",
stage=veda_app_settings.stage_name(),
vpc=vpc.vpc,
database=database,
domain_name=domain.raster_domain_name,
domain=domain,
)

stac_api = StacApiLambdaConstruct(
veda_stack,
"stac-api",
stage=veda_app_settings.stage_name(),
vpc=vpc.vpc,
database=database,
raster_api=raster_api,
domain_name=domain.stac_domain_name,
domain=domain,
)

veda_routes = CloudfrontDistributionConstruct(
veda_stack,
"routes",
stage=veda_app_settings.stage_name(),
raster_api_id=raster_api.raster_api.api_id,
stac_api_id=stac_api.stac_api.api_id,
region=veda_app_settings.cdk_default_region,
)

# TODO this conditional supports deploying a second set of APIs to a separate custom domain and should be removed if no longer necessary
Expand All @@ -85,6 +97,7 @@ def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
alt_raster_api = RasterApiLambdaConstruct(
veda_stack,
"alt-raster-api",
stage=veda_app_settings.stage_name(),
vpc=vpc.vpc,
database=database,
domain_name=alt_domain.raster_domain_name,
Expand All @@ -93,6 +106,7 @@ def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
alt_stac_api = StacApiLambdaConstruct(
veda_stack,
"alt-stac-api",
stage=veda_app_settings.stage_name(),
vpc=vpc.vpc,
database=database,
raster_api=raster_api,
Expand Down
36 changes: 31 additions & 5 deletions database/infrastructure/config.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Veda-backend database construct configuration."""
from typing import Optional

from aws_cdk import aws_ec2, aws_rds
from pydantic import BaseSettings, Field


Expand Down Expand Up @@ -57,12 +58,37 @@ class vedaDBSettings(BaseSettings):
False,
description="Boolean if the RDS should be accessed through a proxy",
)
rds_type: str = Field(
"t3.small",
description="Postgres database type",
rds_instance_class: Optional[str] = Field(
aws_ec2.InstanceClass.BURSTABLE3.value,
description=(
"The instance class of the RDS instance "
"https://docs.aws.amazon.com/cdk/api/v2/python/aws_cdk.aws_ec2/InstanceClass.html"
),
)
rds_instance_size: Optional[str] = Field(
aws_ec2.InstanceSize.SMALL.value,
description=(
"The size of the RDS instance "
"https://docs.aws.amazon.com/cdk/api/v2/python/aws_cdk.aws_ec2/InstanceSize.html"
),
)
rds_engine_full_version: Optional[str] = Field(
aws_rds.PostgresEngineVersion.VER_14.postgres_full_version,
description=(
"The version of the RDS Postgres engine "
"https://docs.aws.amazon.com/cdk/api/v2/python/aws_cdk.aws_rds/PostgresEngineVersion.html"
),
)
rds_engine_major_version: Optional[str] = Field(
aws_rds.PostgresEngineVersion.VER_14.postgres_major_version,
description=(
"The version of the RDS Postgres engine "
"https://docs.aws.amazon.com/cdk/api/v2/python/aws_cdk.aws_rds/PostgresEngineVersion.html"
),
)
storage_encrypted: bool = Field(
False, description="Boolean if the RDS should be storage encrypted"
rds_encryption: Optional[bool] = Field(
False,
description="Boolean if the RDS should be encrypted",
)

class Config:
Expand Down
27 changes: 18 additions & 9 deletions database/infrastructure/construct.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,19 @@ def __init__(

# Custom parameter group
engine = aws_rds.DatabaseInstanceEngine.postgres(
version=aws_rds.PostgresEngineVersion.VER_14
version=aws_rds.PostgresEngineVersion.of(
veda_db_settings.rds_engine_full_version,
veda_db_settings.rds_engine_major_version,
)
)

# RDS Instance Type
rds_instance_type = aws_ec2.InstanceType.of(
aws_ec2.InstanceClass[veda_db_settings.rds_instance_class],
aws_ec2.InstanceSize[veda_db_settings.rds_instance_size],
)

# version=aws_rds.PostgresEngineVersion.postgres_major_version(veda_db_settings.rds_engine_version)
parameter_group = aws_rds.ParameterGroup(
self,
"parameter-group",
Expand All @@ -152,35 +163,33 @@ def __init__(
},
)

# Database Configurations
database_config = {
"id": "rds",
"instance_identifier": f"{stack_name}-postgres",
"vpc": vpc,
"engine": engine,
"instance_type": aws_ec2.InstanceType(
instance_type_identifier=veda_db_settings.rds_type
),
"instance_type": rds_instance_type,
"vpc_subnets": aws_ec2.SubnetSelection(subnet_type=subnet_type),
"deletion_protection": True,
"removal_policy": RemovalPolicy.RETAIN,
"publicly_accessible": veda_db_settings.publicly_accessible,
"parameter_group": parameter_group,
}

if storage_encrypted := veda_db_settings.storage_encrypted:
database_config["storage_encrypted"] = storage_encrypted
if veda_db_settings.rds_encryption:
database_config["storage_encrypted"] = veda_db_settings.rds_encryption

# Create a new database instance from snapshot if provided
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(
snapshot_credentials = aws_rds.SnapshotCredentials.from_generated_secret(
username=veda_db_settings.admin_user
)

database = aws_rds.DatabaseInstanceFromSnapshot(
self,
snapshot_identifier=veda_db_settings.snapshot_id,
credentials=credentials,
credentials=snapshot_credentials,
**database_config,
)
# Or create/update RDS Resource
Expand Down
7 changes: 1 addition & 6 deletions database/runtime/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,7 @@ RUN echo "Using PGSTAC Version ${PGSTAC_VERSION}"

WORKDIR /tmp

COPY database/runtime/requirements.txt /tmp/requirements.txt

RUN pip install --upgrade pip
RUN pip install -r /tmp/requirements.txt -t /asset

RUN pip install pypgstac==${PGSTAC_VERSION} -t /asset
RUN pip install requests "urllib3<2" psycopg[binary,pool] pypgstac==${PGSTAC_VERSION} -t /asset

COPY database/runtime/handler.py /asset/handler.py

Expand Down
4 changes: 3 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ services:
- AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}
# API Config
- VEDA_RASTER_ENABLE_MOSAIC_SEARCH=TRUE
- VEDA_RASTER_EXPORT_ASSUME_ROLE_CREDS_AS_ENVS=TRUE


depends_on:
- database
Expand All @@ -95,7 +97,7 @@ services:
database:
container_name: veda.db
platform: linux/amd64
image: ghcr.io/stac-utils/pgstac:v0.7.9
image: ghcr.io/stac-utils/pgstac:v0.7.10
environment:
- POSTGRES_USER=username
- POSTGRES_PASSWORD=password
Expand Down
25 changes: 0 additions & 25 deletions docs/advanced_configuration.md

This file was deleted.

Loading