DynamoDBBuilder¶
Bases: AbstractAWSResourceBuilder['DynamoDBBuilder', DynamoDBConfig]
Builder for creating AWS DynamoDB tables with organizational standards.
Creates DynamoDB tables with configurable key schemas, Global Secondary Indexes, streaming capabilities, and automatic Parameter Store integration for cross-stack references. Supports pay-per-request billing and comprehensive tagging.
Source code in mare_aws_common_lib/builders/dynamodb_builder.py
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 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | |
Attributes¶
_resource_type = AWSResourceType.DYNAMODB
class-attribute
instance-attribute
¶
Functions¶
_control_consistency()
¶
Validate builder configuration and internal state consistency.
Ensures table base name is set and validates the complete configuration using the DynamoDBConfig model.
Raises:
| Type | Description |
|---|---|
ValueError
|
If table base name is not set |
ValidationError
|
If configuration validation fails |
Source code in mare_aws_common_lib/builders/dynamodb_builder.py
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | |
_set_config()
¶
Create and validate the DynamoDB table configuration.
Merges the base builder configuration with DynamoDB-specific parameters to create a validated DynamoDBConfig object. The configuration includes table naming, key schema, index definitions, streaming settings, and other DynamoDB-specific parameters required for table creation.
The method combines
- Base configuration from self._builder_config (tags, environment, etc.)
- DynamoDB-specific parameter: table_base_name from self._table_base_name
Raises:
| Type | Description |
|---|---|
ValidationError
|
If the DynamoDBConfig validation fails. |
ValueError
|
If table_base_name has not been set via set_table_base_name() |
Side Effects
Sets self._config to a validated DynamoDBConfig instance that can be accessed through the config property after this method completes.
Source code in mare_aws_common_lib/builders/dynamodb_builder.py
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 | |
build(scope)
¶
Build and return the configured DynamoDB table.
Creates a DynamoDB table with partition key, optional sort key, Global Secondary Indexes, streaming configuration, and automatic Parameter Store entries for cross-stack references.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scope
|
Construct
|
CDK construct scope where the table will be created |
required |
Returns:
| Type | Description |
|---|---|
Table
|
Configured DynamoDB Table instance |
Raises:
| Type | Description |
|---|---|
ValidationError
|
If table configuration validation fails |
ValueError
|
If required table base name is not set |
Source code in mare_aws_common_lib/builders/dynamodb_builder.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | |
reset()
¶
Reset the builder to its initial state.
Clears all internal state including table instance and table base name. Called internally to prepare for a new build.
Source code in mare_aws_common_lib/builders/dynamodb_builder.py
23 24 25 26 27 28 29 30 31 | |
set_table_base_name(name)
¶
Set the base name for the DynamoDB table.
The base name will be used to construct the final table name following organizational naming conventions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Base name for the table |
required |
Returns:
| Type | Description |
|---|---|
DynamoDBBuilder
|
Self for method chaining |
Source code in mare_aws_common_lib/builders/dynamodb_builder.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 | |