CDK API Reference

This section documents the da_vinci_cdk (infrastructure) package API.

Application

Application class and Core Stack for DaVinci CDK

class da_vinci_cdk.application.CoreStack(app_name, deployment_id, scope, stack_name, create_hosted_zone=False, event_bus_enabled=False, exception_trap_enabled=False, resource_discovery_table_name=None, resource_discovery_storage_solution=ResourceDiscoveryStorageSolution.SSM, root_domain_name=None, s3_logging_bucket_name=None, s3_logging_bucket_object_retention_days=None, using_external_logging_bucket=False)[source]

Bases: Stack

__init__(app_name, deployment_id, scope, stack_name, create_hosted_zone=False, event_bus_enabled=False, exception_trap_enabled=False, resource_discovery_table_name=None, resource_discovery_storage_solution=ResourceDiscoveryStorageSolution.SSM, root_domain_name=None, s3_logging_bucket_name=None, s3_logging_bucket_object_retention_days=None, using_external_logging_bucket=False)[source]

Bootstrap the initial infrastructure required to stand up a DaVinci

Keyword Arguments:
  • app_name – Name of the application

  • create_hosted_zone – Whether to create a hosted zone for the application if the root_domain_name is set (default: True)

  • deployment_id – Identifier assigned to the installation

  • root_domain_name – Root domain name for the application (default: None)

  • scope – Parent construct for the stack

  • stack_name – Name of the stack

  • s3_logging_bucket_name – Name of the S3 bucket to use for logging (default: None)

  • s3_logging_bucket_object_retention_days – Number of days before objects in the bucket expire (default: None)

  • using_external_logging_bucket – Whether or not a pre-existing bucket is being used for logging(default: False)

class da_vinci_cdk.application.Application(app_name, deployment_id, app_entry=None, app_image_use_lib_base=True, architecture=<aws_cdk.aws_lambda.Architecture object>, custom_context=None, create_hosted_zone=False, disable_docker_image_cache=False, enable_exception_trap=True, enable_logging_bucket=False, enable_event_bus=False, existing_s3_logging_bucket_name=None, log_level='INFO', resource_discovery_storage_solution=ResourceDiscoveryStorageSolution.SSM, root_domain_name=None, s3_logging_bucket_name_postfix=None, s3_logging_bucket_name_prefix=None, s3_logging_bucket_object_retention_days=None)[source]

Bases: object

__init__(app_name, deployment_id, app_entry=None, app_image_use_lib_base=True, architecture=<aws_cdk.aws_lambda.Architecture object>, custom_context=None, create_hosted_zone=False, disable_docker_image_cache=False, enable_exception_trap=True, enable_logging_bucket=False, enable_event_bus=False, existing_s3_logging_bucket_name=None, log_level='INFO', resource_discovery_storage_solution=ResourceDiscoveryStorageSolution.SSM, root_domain_name=None, s3_logging_bucket_name_postfix=None, s3_logging_bucket_name_prefix=None, s3_logging_bucket_object_retention_days=None)[source]

Initialize a new Application object

S3 Logging Bucket Note:

When using an existing S3 logging bucket, the framework will deploy access for itself but it will not manage the bucket or its lifecycle. This is useful for when the bucket is managed by another process or team.

Keyword Arguments:
  • app_entry – Path to the application entry point (default: None)

  • app_image_use_lib_base – Use the library base image for the application (default: True)

  • app_name – Name of the application

  • create_hosted_zone – Whether to create a hosted zone for the application if the root_domain_name is set (default: True)

  • deployment_id – Identifier assigned to the installation

  • enable_exception_trap – Whether to enable the exception trap (default: True)

  • enable_event_bus – Whether to include the event bus stack (default: False)

  • enable_logging_bucket – Whether to enable the logging bucket (default: False)

  • existing_s3_logging_bucket_name – Name of an existing S3 bucket to use for logging (default: None)

  • log_level – Logging level to use for the application (default: INFO)

  • resource_discovery_storage_solution – Storage solution to use for resource discovery (default: SSM)

  • root_domain_name – Root domain name for the application (default: None)

  • s3_logging_bucket_name_postfix – Postfix name of the S3 bucket to use for logging, appends the deployment_id (default: None)

  • s3_logging_bucket_name_prefix – Prefix name of the S3 bucket to use for logging, appends the deployment_id (default: None)

Example

``` from os.path import dirname, abspath

from da_vinci_cdk.application import Application

app = Application(

app_name=’da_vinci’, deployment_id=’test’, app_entry=abspath(dirname(__file__))),

)

app.synth() ```

static generate_stack_name(stack)[source]

Generate a stack name

Keyword Arguments:

stack – Stack to generate the name for

Return type:

str

property lib_container_entry: str

Return the entry point for this library’s container image

add_uninitialized_stack(stack, include_core_dependencies=True)[source]

Add a new unintialized stack to the application. This is useful for adding stacks that take standard parameters.

Keyword Arguments:

stack – Stack to add to the application

Return type:

Stack

synth(**kwargs)[source]

Synthesize the CDK application

Return type:

None

class da_vinci_cdk.application.SideCarApplication(app_name, deployment_id, sidecar_app_name, app_entry=None, app_image_use_lib_base=True, architecture=<aws_cdk.aws_lambda.Architecture object>, log_level='INFO', disable_docker_image_cache=False)[source]

Bases: object

__init__(app_name, deployment_id, sidecar_app_name, app_entry=None, app_image_use_lib_base=True, architecture=<aws_cdk.aws_lambda.Architecture object>, log_level='INFO', disable_docker_image_cache=False)[source]

Initialize a sidecar application that shares resources with a parent application

A sidecar application is a separate CDK application that deploys alongside and connects to an existing da_vinci Application. It shares the parent’s global settings, event bus, and exception trap, but maintains its own infrastructure stacks. Use this for deploying auxiliary services that need to interact with the main application without being part of it.

The sidecar reads configuration from the parent application’s global settings table to automatically discover shared resources. This requires the parent application to be deployed first.

Organization: - Sidecar has its own CDK app and stacks - Shares parent’s deployment_id for resource naming - Gets separate resource names via sidecar_app_name prefix - Connects to parent’s global settings, event bus, exception trap

Request flow differences: - Regular service: Part of main Application CDK tree - Sidecar service: Separate CDK app, connects via resource discovery

Keyword Arguments: app_name – Name of the parent application to connect to deployment_id – Deployment identifier (must match parent application) sidecar_app_name – Unique name for this sidecar (used in resource naming) app_entry – Path to sidecar application code directory app_image_use_lib_base – Build sidecar image on da_vinci base image architecture – Lambda architecture (ARM_64 or X86_64) log_level – Logging level for sidecar functions disable_docker_image_cache – Disable Docker build cache

static generate_stack_name(stack)[source]

Generate a stack name

Keyword Arguments:

stack – Stack to generate the name for

Return type:

str

property lib_container_entry: str

Return the entry point for this library’s container image

add_uninitialized_stack(stack)[source]

Add a new unintialized stack to the application. This is useful for adding stacks that take standard parameters.

Keyword Arguments:

stack – Stack to add to the application

Return type:

Stack

synth(**kwargs)[source]

Synthesize the CDK application

Return type:

None

Stack

class da_vinci_cdk.stack.Stack(app_name, deployment_id, scope, stack_name, app_base_image=None, architecture=None, library_base_image=None, required_stacks=None, requires_event_bus=False, requires_exceptions_trap=False)[source]

Bases: Stack

__init__(app_name, deployment_id, scope, stack_name, app_base_image=None, architecture=None, library_base_image=None, required_stacks=None, requires_event_bus=False, requires_exceptions_trap=False)[source]

Initialize a new Stack object

Keyword Arguments:
  • app_name – Name of the application

  • architecture – Architecture to use for the stack

  • create_sub_domain – Create a sub domain for the stack (default: None)

  • deployment_id – Identifier assigned to the installation

  • scope – Parent construct for the stack

  • stack_name – Name of the stack

  • app_base_image – Base image built for the application (default: None)

  • library_base_image – Base image built for the library (default: None)

  • required_stacks – List of stacks required by this stack (default: None)

  • requires_event_bus – Whether the stack requires an event bus (default: False)

  • requires_exceptions_trap – Whether the stack requires an exception trap (default: True)

Example

``` from da_vinci_cdk.application import Application from da_vinci_cdk.stack import Stack

class MyStack(Stack):
def __init__(self, app_name: str, architecture: str, deployment_id: str,

scope: Construct, stack_name: str) -> None:

super().__init__(

app_name=app_name, architecture=architecture, deployment_id=deployment_id, scope=scope, stack_name=stack_name,

app = Application(

app_name=’da_vinci’, deployment_id=’da_vinci’,

)

app.add_uninitialized_stack(MyStack)

app.synth() ```

add_required_stack(stack)[source]

Add a required dependency stack to the stack instance

Keyword Arguments:

stack – Stack to add as a required stack

static absolute_dir(from_file)[source]

Static method to return the absolute path of a file

Keyword Arguments:

from_file – File to return the absolute path of

Return type:

str

Constructs

Table Construct

Lambda Construct

class da_vinci_cdk.constructs.lambda_function.LambdaFunction(construct_id, entry, index, handler, scope, allow_custom_metrics=False, architecture=None, base_image='public.ecr.aws/lambda/python:3.12', description=None, disable_framework_access_requests=False, disable_image_cache=False, dockerfile='Dockerfile', function_name=None, ignore_exceptions_access=False, ignore_settings_table_access=False, managed_policies=None, memory_size=128, resource_access_requests=None, timeout=None, **kwargs)[source]

Bases: Construct

__init__(construct_id, entry, index, handler, scope, allow_custom_metrics=False, architecture=None, base_image='public.ecr.aws/lambda/python:3.12', description=None, disable_framework_access_requests=False, disable_image_cache=False, dockerfile='Dockerfile', function_name=None, ignore_exceptions_access=False, ignore_settings_table_access=False, managed_policies=None, memory_size=128, resource_access_requests=None, timeout=None, **kwargs)[source]

Creates a Lambda function using a Docker image

Keyword Arguments:
  • construct_id – ID of the construct

  • entry – Path to the entry file

  • index – Name of the entry file

  • handler – Name of the handler

  • scope – Parent construct for the LambdaFunction

  • add_settings_table_access – Add access to the settings table, only if global settings are enabled

  • allow_custom_metrics – Allow custom metrics to be sent to CloudWatch

  • architecture – Architecture to use for the Lambda function

  • base_image – Base image to use for the Lambda function

  • description – Description of the Lambda function

  • disable_framework_access_requests – Disables the automatic creation of resource access policies used by common framework features (e.g. global settings)

  • disable_image_cache – Disables the Docker image cache

  • dockerfile – The name of the Dockerfile to use for the Lambda function

  • function_name – Name of the Lambda function

  • ignore_exceptions_access – Ignore exceptions access

  • ignore_settings_table_access – Ignore settings table access

  • managed_policies – List of managed policies to attach to the Lambda function

  • memory_size – Amount of memory to allocate to the Lambda function

  • timeout – Timeout for the Lambda function

  • kwargs – Additional arguments supported by CDK to pass to the Lambda function

Example

``` from da_vinci_cdk.constructs import LambdaFunction

my_function = LambdaFunction(

construct_id=’MyLambdaFunction’, entry=’path/to/entry’, index=’index.py’, handler=’handler’, scope=scope,

)