Skip to content

Commit

Permalink
Add sample python lambda function
Browse files Browse the repository at this point in the history
  • Loading branch information
hamadsuniverse committed Feb 28, 2024
1 parent 72cd9a3 commit 6df8618
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
3 changes: 3 additions & 0 deletions packages/functions/src/sample-python-lambda/lambda.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

def main(event, context):
return "Hello from Lambda"
Empty file.
23 changes: 16 additions & 7 deletions stacks/ApiStack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,27 @@ import { Duration } from "aws-cdk-lib/core";
export function ApiStack({ stack }: StackContext) {

const {table} = use(DBStack);

// Create the HTTP API
const api = new Api(stack, "Api", {
defaults: {
function: {
// Bind the table name to our API
bind: [table],
},
function: {
// Bind the table name to our API
bind: [table],
},
},
routes: {
"POST /": "packages/functions/src/lambda.main",
},
// Sample TypeScript lambda function
"POST /": "packages/functions/src/lambda.main",
// Sample Pyhton lambda function
"GET /": {
function: {
handler: "packages/functions/src/sample-python-lambda/lambda.main",
runtime: "python3.11",
timeout: "60 seconds",
}
},
}
});

// cache policy to use with cloudfront as reverse proxy to avoid cors
Expand Down

0 comments on commit 6df8618

Please sign in to comment.