Skip to content

Commit

Permalink
add params for package versions
Browse files Browse the repository at this point in the history
* tipg
* titiler-pgstac
* stac-fastapi
* pgstac
  • Loading branch information
hrodmn committed Nov 23, 2023
1 parent 1e39ddb commit 224a60e
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 14 deletions.
11 changes: 9 additions & 2 deletions lib/database/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export class PgStacDatabase extends Construct {
timeout: Duration.minutes(2),
code: aws_lambda.Code.fromDockerBuild(__dirname, {
file: "bootstrapper_runtime/Dockerfile",
buildArgs: {PGSTAC_VERSION: DEFAULT_PGSTAC_VERSION, PYTHON_VERSION: "3.11"}
buildArgs: {PGSTAC_VERSION: props.pgstacVersion || DEFAULT_PGSTAC_VERSION, PYTHON_VERSION: "3.11"}
}),
// overwrites defaults with user-provided configurable properties
...props.bootstrapperLambdaFunctionOptions,
Expand Down Expand Up @@ -120,7 +120,7 @@ export class PgStacDatabase extends Construct {

// if props.lambdaFunctionOptions doesn't have 'code' defined, update pgstac_version (needed for default runtime)
if (!props.bootstrapperLambdaFunctionOptions?.code) {
customResourceProperties["pgstac_version"] = DEFAULT_PGSTAC_VERSION;
customResourceProperties["pgstac_version"] = props.pgstacVersion;
}
// this.connections = props.database.connections;
new CustomResource(this, "bootstrapper", {
Expand Down Expand Up @@ -193,6 +193,13 @@ export interface PgStacDatabaseProps extends rds.DatabaseInstanceProps {
*/
readonly pgstacUsername?: string;

/**
* Version of pgstac to install on the database
*
* @default 0.7.10
*/
readonly pgstacVersion?: string;

/**
* Lambda function Custom Resource properties. A custom resource property is going to be created
* to trigger the boostrapping lambda function. This parameter allows the user to specify additional properties
Expand Down
11 changes: 10 additions & 1 deletion lib/stac-api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import { HttpLambdaIntegration } from "@aws-cdk/aws-apigatewayv2-integrations-al
import { Construct } from "constructs";
import { CustomLambdaFunctionProps } from "../utils";

const DEFAULT_STAC_FASTAPI_VERSION = "2.4.8";

export class PgStacApiLambda extends Construct {
readonly url: string;
public stacApiLambdaFunction: lambda.Function;
Expand All @@ -31,7 +33,7 @@ export class PgStacApiLambda extends Construct {
timeout: Duration.seconds(30),
code: lambda.Code.fromDockerBuild(__dirname, {
file: "runtime/Dockerfile",
buildArgs: { PYTHON_VERSION: '3.11' },
buildArgs: { PYTHON_VERSION: '3.11', STAC_FASTAPI_VERSION: props.stacFastapiVersion || DEFAULT_STAC_FASTAPI_VERSION },
}),
// overwrites defaults with user-provided configurable properties
...props.lambdaFunctionOptions,
Expand Down Expand Up @@ -88,6 +90,13 @@ export interface PgStacApiLambdaProps {
*/
readonly dbSecret: secretsmanager.ISecret;

/**
* Version of stac-fastapi to install in the Lambda Docker image
*
* @default 2.4.8
*/
readonly stacFastapiVersion?: string;

/**
* Customized environment variables to send to fastapi-pgstac runtime.
*/
Expand Down
9 changes: 8 additions & 1 deletion lib/stac-api/runtime/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,15 @@ FROM --platform=linux/amd64 public.ecr.aws/lambda/python:${PYTHON_VERSION}
WORKDIR /tmp
RUN python -m pip install pip -U

ARG STAC_FASTAPI_VERSION=2.4.8
COPY runtime/requirements.txt requirements.txt
RUN python -m pip install -r requirements.txt "mangum>=0.14,<0.15" -t /asset --no-binary pydantic
RUN python -m pip install -r requirements.txt \
stac-fastapi.api==${STAC_FASTAPI_VERSION} \
stac-fastapi.extensions==${STAC_FASTAPI_VERSION} \
stac-fastapi.pgstac==${STAC_FASTAPI_VERSION} \
stac-fastapi.types==${STAC_FASTAPI_VERSION} \
"mangum>=0.14,<0.15" \
-t /asset --no-binary pydantic

RUN mkdir -p /asset/src
COPY runtime/src/*.py /asset/src/
Expand Down
6 changes: 1 addition & 5 deletions lib/stac-api/runtime/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
stac-fastapi.api==2.4.8
stac-fastapi.extensions==2.4.8
stac-fastapi.pgstac==2.4.8
stac-fastapi.types==2.4.8
# https://github.com/stac-utils/stac-fastapi/pull/466
# pin pygeoif: https://github.com/stac-utils/stac-fastapi/pull/466
pygeoif==0.7
starlette_cramjam
10 changes: 9 additions & 1 deletion lib/tipg-api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import {
import { Construct } from "constructs";
import { CustomLambdaFunctionProps } from "../utils";

const DEFAULT_TIPG_VERSION = "0.3.1";

export class TiPgApiLambda extends Construct {
readonly url: string;
public tiPgLambdaFunction: lambda.Function;
Expand All @@ -29,7 +31,7 @@ import {
timeout: Duration.seconds(30),
code: lambda.Code.fromDockerBuild(__dirname, {
file: "runtime/Dockerfile",
buildArgs: { PYTHON_VERSION: '3.11' },
buildArgs: { PYTHON_VERSION: '3.11', TIPG_VERSION: props.tipgVersion || DEFAULT_TIPG_VERSION },
}),
// overwrites defaults with user-provided configurable properties
...props.lambdaFunctionOptions,
Expand Down Expand Up @@ -87,6 +89,12 @@ import {
*/
readonly dbSecret: secretsmanager.ISecret;

/**
* Version of tipg to install in the Lambda Docker image
*
* @default 0.3.1
*/
readonly tipgVersion?: string;

/**
* Customized environment variables to send to titiler-pgstac runtime.
Expand Down
3 changes: 2 additions & 1 deletion lib/tipg-api/runtime/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ FROM --platform=linux/amd64 public.ecr.aws/lambda/python:${PYTHON_VERSION}
WORKDIR /tmp
RUN python -m pip install pip -U

RUN python -m pip install tipg==0.3.1 "mangum>=0.14,<0.15" -t /asset --no-binary pydantic
ARG TIPG_VERSION=0.3.1
RUN python -m pip install tipg==${TIPG_VERSION} "mangum>=0.14,<0.15" -t /asset --no-binary pydantic

# Reduce package size and remove useless files
RUN cd /asset && find . -type f -name '*.pyc' | while read f; do n=$(echo $f | sed 's/__pycache__\///' | sed 's/.cpython-[0-9]*//'); cp $f $n; done;
Expand Down
10 changes: 9 additions & 1 deletion lib/titiler-pgstac-api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
import { Construct } from "constructs";
import { CustomLambdaFunctionProps } from "../utils";

const DEFAULT_TITILER_PGSTAC_VERSION = "0.5.1";

// default settings that can be overridden by the user-provided environment.
let defaultTitilerPgstacEnv :{ [key: string]: any } = {
Expand Down Expand Up @@ -47,7 +48,7 @@ import { CustomLambdaFunctionProps } from "../utils";
timeout: Duration.seconds(30),
code: lambda.Code.fromDockerBuild(__dirname, {
file: "runtime/Dockerfile",
buildArgs: { PYTHON_VERSION: '3.11' }
buildArgs: { PYTHON_VERSION: '3.11' , TITILER_PGSTAC_VERSION: props.titilerPgstacVersion || DEFAULT_TITILER_PGSTAC_VERSION }
}),
// overwrites defaults with user-provided configurable properties
...props.lambdaFunctionOptions,
Expand Down Expand Up @@ -113,6 +114,13 @@ import { CustomLambdaFunctionProps } from "../utils";
*/
readonly dbSecret: secretsmanager.ISecret;

/**
* Version of titiler-pgstac to install in the Lambda Docker image
*
* @default 0.5.1
*/
readonly titilerPgstacVersion?: string;

/**
* Customized environment variables to send to titiler-pgstac runtime. These will be merged with `defaultTitilerPgstacEnv`.
* The database secret arn is automatically added to the environment variables at deployment.
Expand Down
3 changes: 2 additions & 1 deletion lib/titiler-pgstac-api/runtime/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ FROM --platform=linux/amd64 public.ecr.aws/lambda/python:${PYTHON_VERSION}
WORKDIR /tmp
RUN python -m pip install pip -U

ARG TITILER_PGSTAC_VERSION=0.5.1
COPY runtime/requirements.txt requirements.txt
RUN python -m pip install -r requirements.txt "mangum>=0.14,<0.15" -t /asset
RUN python -m pip install -r requirements.txt "mangum>=0.14,<0.15" titiler.pgstac==${TITILER_PGSTAC_VERSION} -t /asset

# Reduce package size and remove useless files
RUN find /asset -type f -name '*.pyc' | while read f; do n=$(echo $f | sed 's/__pycache__\///' | sed 's/.cpython-[0-9]*//'); cp $f $n; done;
Expand Down
1 change: 0 additions & 1 deletion lib/titiler-pgstac-api/runtime/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
titiler.pgstac==0.5.1
psycopg[binary, pool]

0 comments on commit 224a60e

Please sign in to comment.