-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
56 lines (47 loc) · 1.66 KB
/
app.py
File metadata and controls
56 lines (47 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env python3
import os
import aws_cdk as cdk
from lib.auth_stack import AuthStack
from lib.lambda_url_streaming_stack import LambdaUrlStreamingStack
from lib.websocket_api_streaming_stack import WebSocketApiStreamingStack
from lib.appsync_streaming_stack import AppSyncStreamingStack
from aws_cdk import aws_iam as iam
from cdk_nag import AwsSolutionsChecks, HIPAASecurityChecks, NIST80053R5Checks
app = cdk.App()
# Get AWS account and region from environment or CDK context
env = cdk.Environment(
account=os.getenv("CDK_DEFAULT_ACCOUNT"), region=os.getenv("CDK_DEFAULT_REGION")
)
# Shared authentication stack
auth_stack = AuthStack(app, "ServerlessLlmStreamingAuthStack", env=env)
# Option 1: Lambda Function URL with Response Streaming
lambda_url_stack = LambdaUrlStreamingStack(
app,
"LambdaUrlStreamingStack",
user_pool=auth_stack.user_pool,
user_pool_client=auth_stack.user_pool_client,
env=env,
)
# Option 2: API Gateway WebSocket API
websocket_stack = WebSocketApiStreamingStack(
app,
"WebSocketApiStreamingStack",
user_pool=auth_stack.user_pool,
user_pool_client=auth_stack.user_pool_client,
env=env,
)
# Option 3: AppSync with GraphQL Subscriptions (Real-time streaming with Cognito)
appsync_streaming_stack = AppSyncStreamingStack(
app,
"AppSyncStreamingStack",
user_pool=auth_stack.user_pool,
user_pool_client=auth_stack.user_pool_client,
env=env,
)
# Add stack dependencies
lambda_url_stack.add_dependency(auth_stack)
websocket_stack.add_dependency(auth_stack)
appsync_streaming_stack.add_dependency(auth_stack)
# Add cdk-nag checks to all stacks
cdk.Aspects.of(app).add(AwsSolutionsChecks())
app.synth()