-
Notifications
You must be signed in to change notification settings - Fork 359
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add instance of Quickwit lambda with mock data generation
- Loading branch information
Showing
36 changed files
with
1,238 additions
and
209 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ __pycache__ | |
.pytest_cache | ||
.venv | ||
*.egg-info | ||
build/ | ||
|
||
# CDK asset staging directory | ||
.cdk.staging | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/usr/bin/env python3 | ||
import os | ||
|
||
import aws_cdk as cdk | ||
|
||
from cdk.stacks.base_stack import BaseQuickwitStack | ||
from cdk.stacks.hdfs_stack import HdfsStack | ||
from cdk.stacks.mock_data_stack import MockDataStack | ||
|
||
|
||
BASE_STACK_NAME = "BaseQuickwitStack" | ||
HDFS_STACK_NAME = "HdfsStack" | ||
MOCK_DATA_STACK_NAME = "MockDataStack" | ||
|
||
|
||
app = cdk.App() | ||
|
||
BaseQuickwitStack(app, BASE_STACK_NAME) | ||
|
||
HdfsStack( | ||
app, | ||
HDFS_STACK_NAME, | ||
env=cdk.Environment( | ||
account=os.getenv("CDK_ACCOUNT"), region=os.getenv("CDK_REGION") | ||
), | ||
) | ||
|
||
MockDataStack( | ||
app, | ||
MOCK_DATA_STACK_NAME, | ||
env=cdk.Environment( | ||
account=os.getenv("CDK_ACCOUNT"), region=os.getenv("CDK_REGION") | ||
), | ||
) | ||
|
||
app.synth() |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
from typing import Optional | ||
|
||
from aws_cdk import Stack, CfnParameter | ||
from constructs import Construct | ||
|
||
from .services import quickwit_service | ||
|
||
|
||
class BaseQuickwitStack(Stack): | ||
"""Base componentes required to run Quickwit serverless.""" | ||
|
||
def __init__( | ||
self, | ||
scope: Construct, | ||
construct_id: str, | ||
**kwargs, | ||
) -> None: | ||
super().__init__(scope, construct_id, **kwargs) | ||
|
||
index_id_param = CfnParameter( | ||
self, | ||
"quickwitIndexId", | ||
type="String", | ||
description="The ID of the Quickwit index", | ||
) | ||
index_config_bucket_param = CfnParameter( | ||
self, | ||
"quickwitIndexConfigBucket", | ||
type="String", | ||
description="The S3 bucket name of the Quickwit index config", | ||
) | ||
index_config_key_param = CfnParameter( | ||
self, | ||
"quickwitIndexConfigKey", | ||
type="String", | ||
description="The S3 object key of the Quickwit index config", | ||
) | ||
|
||
quickwit_service.QuickwitService( | ||
self, | ||
"Quickwit", | ||
index_id=index_id_param.value_as_string, | ||
index_config_bucket=index_config_bucket_param.value_as_string, | ||
index_config_key=index_config_key_param.value_as_string, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import aws_cdk | ||
from aws_cdk import Stack, aws_s3_assets | ||
from constructs import Construct | ||
import yaml | ||
|
||
from .services import quickwit_service | ||
|
||
|
||
INDEX_STORE_BUCKET_NAME_EXPORT_NAME = "hdfs-index-store-bucket-name" | ||
INDEXER_FUNCTION_NAME_EXPORT_NAME = "hdfs-indexer-function-name" | ||
SEARCHER_FUNCTION_NAME_EXPORT_NAME = "hdfs-searcher-function-name" | ||
|
||
|
||
class HdfsStack(Stack): | ||
def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None: | ||
super().__init__(scope, construct_id, **kwargs) | ||
|
||
index_config_local_path = "../../config/tutorials/hdfs-logs/index-config.yaml" | ||
|
||
with open(index_config_local_path) as f: | ||
index_config_dict = yaml.safe_load(f) | ||
index_id = index_config_dict["index_id"] | ||
|
||
index_config = aws_s3_assets.Asset( | ||
self, | ||
"mock-data-index-config", | ||
path=index_config_local_path, | ||
) | ||
qw_svc = quickwit_service.QuickwitService( | ||
self, | ||
"Quickwit", | ||
index_id=index_id, | ||
index_config_bucket=index_config.s3_bucket_name, | ||
index_config_key=index_config.s3_object_key, | ||
) | ||
|
||
aws_cdk.CfnOutput( | ||
self, | ||
"index-store-bucket-name", | ||
value=qw_svc.bucket.bucket_name, | ||
export_name=INDEX_STORE_BUCKET_NAME_EXPORT_NAME, | ||
) | ||
aws_cdk.CfnOutput( | ||
self, | ||
"indexer-function-name", | ||
value=qw_svc.indexer.lambda_function.function_name, | ||
export_name=INDEXER_FUNCTION_NAME_EXPORT_NAME, | ||
) | ||
aws_cdk.CfnOutput( | ||
self, | ||
"searcher-function-name", | ||
value=qw_svc.searcher.lambda_function.function_name, | ||
export_name=SEARCHER_FUNCTION_NAME_EXPORT_NAME, | ||
) |
Oops, something went wrong.