Skip to content

Commit 1390588

Browse files
committed
update deployment to use UV
1 parent ca250f8 commit 1390588

File tree

11 files changed

+363
-188
lines changed

11 files changed

+363
-188
lines changed

.github/workflows/deploy.yml

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -40,23 +40,11 @@ jobs:
4040
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
4141
aws-region: us-east-1
4242

43-
- name: Set up Node.js
44-
uses: actions/setup-node@v6
45-
with:
46-
node-version: '24.x'
47-
48-
- name: Install cdk
49-
run: npm install -g
50-
51-
- name: Set up Python
52-
uses: actions/setup-python@v6
53-
with:
54-
python-version: '3.x'
55-
43+
- name: Set up uv
44+
uses: astral-sh/setup-uv@v5
45+
5646
- name: Install dependencies
57-
run: |
58-
python -m pip install --upgrade pip
59-
python -m pip install -r requirements-cdk.txt
47+
run: uv sync --all-packages && npm install -g aws-cdk@2.159.1
6048

6149
# Let's wait a bit to make sure package is available on pypi
6250
- name: Sleep for 120 seconds
@@ -65,7 +53,7 @@ jobs:
6553

6654
# Build and Deploy CDK application
6755
- name: Build & Deploy
68-
run: npm run cdk -- deploy ${{ secrets.STACK_NAME }}-lambda-${{ secrets.STACK_STAGE }} --require-approval never
56+
run: uv run cdk deploy ${{ secrets.STACK_NAME }}-lambda-${{ secrets.STACK_STAGE }} --require-approval never
6957
env:
7058
TITILER_STACK_NAME: ${{ secrets.STACK_NAME }}
7159
TITILER_STACK_STAGE: ${{ secrets.STACK_STAGE }}

deployment/aws/cdk/app.py renamed to deployment/aws/app.py

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,55 @@
99
from aws_cdk import aws_lambda
1010
from aws_cdk import aws_logs as logs
1111
from aws_cdk.aws_apigatewayv2_integrations import HttpLambdaIntegration
12-
from config import StackSettings
1312
from constructs import Construct
13+
from pydantic_settings import BaseSettings, SettingsConfigDict
1414

15-
settings = StackSettings()
15+
16+
class StackSettings(BaseSettings):
17+
"""Application settings"""
18+
19+
name: str = "titiler"
20+
stage: str = "production"
21+
22+
owner: Optional[str] = None
23+
client: Optional[str] = None
24+
25+
# Default options are optimized for CloudOptimized GeoTIFF
26+
# For more information on GDAL env see: https://gdal.org/user/configoptions.html
27+
# or https://developmentseed.org/titiler/advanced/performance_tuning/
28+
env: Dict = {
29+
"GDAL_CACHEMAX": "200", # 200 mb
30+
"GDAL_DISABLE_READDIR_ON_OPEN": "EMPTY_DIR",
31+
"GDAL_INGESTED_BYTES_AT_OPEN": "32768", # get more bytes when opening the files.
32+
"GDAL_HTTP_MERGE_CONSECUTIVE_RANGES": "YES",
33+
"GDAL_HTTP_MULTIPLEX": "YES",
34+
"GDAL_HTTP_VERSION": "2",
35+
"PYTHONWARNINGS": "ignore",
36+
"VSI_CACHE": "TRUE",
37+
"VSI_CACHE_SIZE": "5000000", # 5 MB (per file-handle)
38+
}
39+
40+
# S3 bucket names where TiTiler could do HEAD and GET Requests
41+
# specific private and public buckets MUST be added if you want to use s3:// urls
42+
# You can whitelist all bucket by setting `*`.
43+
# ref: https://docs.aws.amazon.com/AmazonS3/latest/userguide/s3-arn-format.html
44+
buckets: List = []
45+
46+
# S3 key pattern to limit the access to specific items (e.g: "my_data/*.tif")
47+
key: str = "*"
48+
49+
###########################################################################
50+
# AWS LAMBDA
51+
# The following settings only apply to AWS Lambda deployment
52+
# more about lambda config: https://www.sentiatechblog.com/aws-re-invent-2020-day-3-optimizing-lambda-cost-with-multi-threading
53+
timeout: int = 10
54+
memory: int = 1536
55+
56+
# The maximum of concurrent executions you want to reserve for the function.
57+
# Default: - No specific limit - account limit.
58+
max_concurrent: Optional[int] = None
59+
60+
model_config = SettingsConfigDict(env_prefix="TITILER_STACK_", env_file=".env")
1661

1762

1863
class titilerLambdaStack(Stack):
@@ -112,6 +157,7 @@ def __init__(
112157

113158

114159
app = App()
160+
settings = StackSettings()
115161

116162
perms = []
117163
if settings.buckets:

deployment/aws/cdk.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"app": "python3 cdk/app.py"
2+
"app": "python3 app.py"
33
}

deployment/aws/cdk/__init__.py

Lines changed: 0 additions & 1 deletion
This file was deleted.

deployment/aws/cdk/config.py

Lines changed: 0 additions & 52 deletions
This file was deleted.

deployment/aws/package-lock.json

Lines changed: 0 additions & 81 deletions
This file was deleted.

deployment/aws/package.json

Lines changed: 0 additions & 13 deletions
This file was deleted.

deployment/aws/pyproject.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[project]
2+
name = "titiler-cdk"
3+
version = "0.0.0"
4+
5+
dependencies = [
6+
# aws cdk
7+
"aws-cdk-lib==2.201.0",
8+
"constructs>=10.0.0",
9+
# pydantic settings
10+
"pydantic~=2.0",
11+
"pydantic-settings~=2.0",
12+
]

deployment/aws/requirements-cdk.txt

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)