pub struct TableBuilder<T: TableBuilderState> { /* private fields */ }Expand description
Builder for DynamoDB tables.
See https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-dynamodb-table.html
Supports both pay-per-request and provisioned billing modes. The builder enforces the correct configuration based on the chosen billing mode.
§Example
use rusty_cdk_core::stack::StackBuilder;
use rusty_cdk_core::dynamodb::{TableBuilder, Key, AttributeType};
use rusty_cdk_core::wrappers::*;
use rusty_cdk_macros::{string_with_only_alphanumerics_and_underscores, non_zero_number};
let mut stack_builder = StackBuilder::new();
let partition_key = Key::new(
string_with_only_alphanumerics_and_underscores!("id"),
AttributeType::String
);
let sort_key = Key::new(
string_with_only_alphanumerics_and_underscores!("timestamp"),
AttributeType::Number
);
let on_demand_table = TableBuilder::new("on-demand-table", partition_key)
.sort_key(sort_key)
.pay_per_request_billing()
.build(&mut stack_builder);Implementations§
Source§impl<T: TableBuilderState> TableBuilder<T>
impl<T: TableBuilderState> TableBuilder<T>
Sourcepub fn sort_key(self, key: Key) -> Self
pub fn sort_key(self, key: Key) -> Self
Sets the sort key for the table. The sort key is also known as the range key.
Sourcepub fn table_name(self, name: StringWithOnlyAlphaNumericsAndUnderscores) -> Self
pub fn table_name(self, name: StringWithOnlyAlphaNumericsAndUnderscores) -> Self
Sets the name of the table. If not specified, a name will be generated.
pub fn update_replace_and_deletion_policy( self, update_replace_policy: UpdateReplacePolicy, deletion_policy: DeletionPolicy, ) -> Self
Sourcepub fn pay_per_request_billing(self) -> TableBuilder<PayPerRequestState>
pub fn pay_per_request_billing(self) -> TableBuilder<PayPerRequestState>
Configures the table to use pay-per-request billing.
With this mode, you pay per request and can optionally set max throughput limits.
Sourcepub fn provisioned_billing(self) -> TableBuilder<ProvisionedStateStart>
pub fn provisioned_billing(self) -> TableBuilder<ProvisionedStateStart>
Configures the table to use provisioned billing.
With this mode, you must specify read and write capacity units.
Source§impl TableBuilder<PayPerRequestState>
impl TableBuilder<PayPerRequestState>
Sourcepub fn max_read_capacity(self, capacity: NonZeroNumber) -> Self
pub fn max_read_capacity(self, capacity: NonZeroNumber) -> Self
Sets the maximum read capacity for a pay-per-request table. This is an optional property.
Sourcepub fn max_write_capacity(self, capacity: NonZeroNumber) -> Self
pub fn max_write_capacity(self, capacity: NonZeroNumber) -> Self
Sets the maximum write capacity for a pay-per-request table. This is an optional property.
pub fn build(self, stack_builder: &mut StackBuilder) -> TableRef
Source§impl TableBuilder<ProvisionedStateStart>
impl TableBuilder<ProvisionedStateStart>
Sourcepub fn read_capacity(
self,
capacity: NonZeroNumber,
) -> TableBuilder<ProvisionedStateReadSet>
pub fn read_capacity( self, capacity: NonZeroNumber, ) -> TableBuilder<ProvisionedStateReadSet>
Sets the read capacity for a provisioned table. This is a required property for provisioned tables.
Source§impl TableBuilder<ProvisionedStateReadSet>
impl TableBuilder<ProvisionedStateReadSet>
Sourcepub fn write_capacity(
self,
capacity: NonZeroNumber,
) -> TableBuilder<ProvisionedStateWriteSet>
pub fn write_capacity( self, capacity: NonZeroNumber, ) -> TableBuilder<ProvisionedStateWriteSet>
Sets the write capacity for a provisioned table. This is a required property for provisioned tables.