Skip to content

Commit

Permalink
feat(dynamodb): configure billing mode and deletion protection
Browse files Browse the repository at this point in the history
  • Loading branch information
Chriscbr committed Sep 10, 2024
1 parent 0330544 commit f586e98
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
11 changes: 11 additions & 0 deletions dynamodb/dynamodb-types.w
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,11 @@ pub struct StreamConsumerOptions {
startingPosition: str?;
}

pub enum BillingMode {
PAY_PER_REQUEST,
PROVISIONED
}

pub struct TableProps {
name: str?;
attributes: Array<AttributeDefinition>;
Expand All @@ -190,6 +195,12 @@ pub struct TableProps {
timeToLiveAttribute: str?;
globalSecondaryIndex: Array<GlobalSecondaryIndex>?;
pointInTimeRecovery: bool?;
billingMode: BillingMode?;

/// Enables deletion protection for table. Disabled by default.
///
/// For the Terraform AWS provider, this will also enable `lifecycle { prevent_destroy = true }`
deletionProtection: bool?;
}

pub struct Credentials {
Expand Down
8 changes: 7 additions & 1 deletion dynamodb/dynamodb.tf-aws.w
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ pub class Table_tfaws impl dynamodb_types.ITable {
pub connection: dynamodb_types.Connection;

new(props: dynamodb_types.TableProps) {
let billingMode = props.billingMode ?? dynamodb_types.BillingMode.PAY_PER_REQUEST;

this.table = new tfaws.dynamodbTable.DynamodbTable({
// Generate a unique name for the table:
// - Replace slashes with hyphens
Expand All @@ -56,7 +58,11 @@ pub class Table_tfaws impl dynamodb_types.ITable {
attribute: props.attributes,
hashKey: props.hashKey,
rangeKey: props.rangeKey,
billingMode: "PAY_PER_REQUEST",
billingMode: "{billingMode}",
deletionProtectionEnabled: props.deletionProtection ?? false,
lifecycle: {
preventDestroy: props.deletionProtection ?? false,
},
streamEnabled: true,
streamViewType: "NEW_AND_OLD_IMAGES",
pointInTimeRecovery: {
Expand Down

0 comments on commit f586e98

Please sign in to comment.