Skip to content

Commit 3a91a37

Browse files
authored
feat(stac-api): add stac api lambda function field (#43)
* added a field of type PythonFunction to PgStacApiLambda construct to give access to users to the STAC API lambda function
1 parent 86fd1a4 commit 3a91a37

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

lib/stac-api/index.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { Construct } from "constructs";
1616

1717
export class PgStacApiLambda extends Construct {
1818
readonly url: string;
19+
public stacApiLambdaFunction: PythonFunction;
1920

2021
constructor(scope: Construct, id: string, props: PgStacApiLambdaProps) {
2122
super(scope, id);
@@ -26,7 +27,7 @@ export class PgStacApiLambda extends Construct {
2627
handler: "handler",
2728
};
2829

29-
const handler = new PythonFunction(this, "stac-api", {
30+
this.stacApiLambdaFunction = new PythonFunction(this, "stac-api", {
3031
...apiCode,
3132
/**
3233
* NOTE: Unable to use Py3.9, due to issues with hashes:
@@ -53,11 +54,11 @@ export class PgStacApiLambda extends Construct {
5354
memorySize: 8192,
5455
});
5556

56-
props.dbSecret.grantRead(handler);
57-
handler.connections.allowTo(props.db, ec2.Port.tcp(5432));
57+
props.dbSecret.grantRead(this.stacApiLambdaFunction);
58+
this.stacApiLambdaFunction.connections.allowTo(props.db, ec2.Port.tcp(5432));
5859

5960
const stacApi = new HttpApi(this, `${Stack.of(this).stackName}-stac-api`, {
60-
defaultIntegration: new HttpLambdaIntegration("integration", handler),
61+
defaultIntegration: new HttpLambdaIntegration("integration", this.stacApiLambdaFunction),
6162
});
6263

6364
this.url = stacApi.url!;

0 commit comments

Comments
 (0)