Skip to content

Commit

Permalink
docs(examples/python-app): one example to rule them all
Browse files Browse the repository at this point in the history
  • Loading branch information
mrgrain committed Jun 23, 2022
1 parent 1199b2e commit 932f793
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion examples/python-app/python_app/python_app_stack.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,32 @@
from aws_cdk import Stack
import aws_cdk.aws_lambda as lambda_
import aws_cdk.aws_s3 as s3
import aws_cdk.aws_s3_deployment as s3_deployment
from constructs import Construct
from mrgrain.cdk_esbuild import TypeScriptCode, BuildOptions
from mrgrain.cdk_esbuild import (
BuildOptions,
InlineTypeScriptCode,
TypeScriptCode,
TypeScriptSource,
)


class PythonAppStack(Stack):
def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
super().__init__(scope, construct_id, **kwargs)

s3_deployment.BucketDeployment(
self,
"Website",
sources=[
TypeScriptSource("lambda-handler/index.ts", copy_dir="lambda-handler")
],
destination_bucket=s3.Bucket(
self,
"Bucket",
),
)

lambda_.Function(
self,
"Function",
Expand All @@ -20,3 +39,18 @@ def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
),
),
)

lambda_.Function(
self,
"InlineFunction",
runtime=lambda_.Runtime.NODEJS_16_X,
handler="index.handler",
code=InlineTypeScriptCode(
"""
const hello: string = 'world';
export function handler() {
console.log(hello);
}
"""
),
)

0 comments on commit 932f793

Please sign in to comment.