Skip to content

Dynamodb updates #7267

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Mar 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions javascriptv3/example_code/dynamodb/actions/create-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@ export const main = async () => {
KeyType: "HASH",
},
],
ProvisionedThroughput: {
ReadCapacityUnits: 1,
WriteCapacityUnits: 1,
},
BillingMode: "PAY_PER_REQUEST",
});

const response = await client.send(command);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@ describe("delete-table", () => {
KeyType: "HASH",
},
],
ProvisionedThroughput: {
ReadCapacityUnits: 1,
WriteCapacityUnits: 1,
},
BillingMode: "PAY_PER_REQUEST",
});

await client.send(createTableCommand);
Expand Down
2 changes: 1 addition & 1 deletion ruby/Gemfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
source 'https://rubygems.org'
ruby '3.1.2'
ruby '3.3.7'

gem 'aws-sdk'
gem 'cli-ui'
Expand Down
3 changes: 2 additions & 1 deletion ruby/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1520,6 +1520,7 @@ GEM

PLATFORMS
arm64-darwin-22
x64-mingw-ucrt
x86_64-linux

DEPENDENCIES
Expand All @@ -1545,7 +1546,7 @@ DEPENDENCIES
zip

RUBY VERSION
ruby 3.1.2p20
ruby 3.3.7p123

BUNDLED WITH
2.3.7
2 changes: 1 addition & 1 deletion ruby/example_code/dynamodb/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,4 +184,4 @@ To learn more about the contributing process, see [CONTRIBUTING.md](../../../CON

Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.

SPDX-License-Identifier: Apache-2.0
SPDX-License-Identifier: Apache-2.0
2 changes: 1 addition & 1 deletion ruby/example_code/dynamodb/scaffold.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def create_table(table_name)
{ attribute_name: 'year', attribute_type: 'N' },
{ attribute_name: 'title', attribute_type: 'S' }
],
provisioned_throughput: { read_capacity_units: 10, write_capacity_units: 10 }
billing_mode: 'PAY_PER_REQUEST'
)
@dynamo_resource.client.wait_until(:table_exists, table_name: table_name)
@table
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
use std::collections::HashMap;

use aws_sdk_dynamodb::types::{AttributeDefinition, KeySchemaElement, ProvisionedThroughput};
use aws_sdk_dynamodb::types::{AttributeDefinition, KeySchemaElement, BillingMode};
use aws_sdk_rekognition::types::Label;
use photo_asset_management::{
common::{init_tracing_subscriber, Common},
Expand All @@ -27,13 +27,8 @@ async fn create_table(common: &Common) -> Result<(), impl std::error::Error> {
.attribute_definitions(
AttributeDefinition::builder()
.attribute_name("Label")
.attribute_type(aws_sdk_dynamodb::types::ScalarAttributeType::S)
.build(),
)
.provisioned_throughput(
ProvisionedThroughput::builder()
.write_capacity_units(1)
.read_capacity_units(1)
.attribute_type(aws_sdk_dynamodb::types::ScalarAttributeType::S),
.billing_mode(aws_sdk_dynamodb::types::BillingMode::PayPerRequest)
.build(),
)
.send()
Expand Down
10 changes: 2 additions & 8 deletions rustv1/examples/dynamodb/src/bin/crud.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use aws_sdk_dynamodb::error::SdkError;
use aws_sdk_dynamodb::operation::create_table::CreateTableError;
use aws_sdk_dynamodb::operation::put_item::PutItemError;
use aws_sdk_dynamodb::types::{
AttributeDefinition, AttributeValue, KeySchemaElement, KeyType, ProvisionedThroughput,
AttributeDefinition, AttributeValue, BillingMode, KeySchemaElement, KeyType,
ScalarAttributeType, Select, TableStatus,
};
use aws_sdk_dynamodb::{config::Region, meta::PKG_VERSION, Client, Error};
Expand Down Expand Up @@ -63,18 +63,12 @@ async fn make_table(
.build()
.expect("creating KeySchemaElement");

let pt = ProvisionedThroughput::builder()
.read_capacity_units(10)
.write_capacity_units(5)
.build()
.expect("creating ProvisionedThroughput");

match client
.create_table()
.table_name(table)
.key_schema(ks)
.attribute_definitions(ad)
.provisioned_throughput(pt)
.billing_mode(BillingMode::PayPerRequest)
.send()
.await
{
Expand Down
10 changes: 2 additions & 8 deletions rustv1/examples/dynamodb/src/bin/dynamodb-helloworld.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

use aws_config::meta::region::RegionProviderChain;
use aws_sdk_dynamodb::types::{
AttributeDefinition, KeySchemaElement, KeyType, ProvisionedThroughput, ScalarAttributeType,
AttributeDefinition, BillingMode, KeySchemaElement, KeyType, ScalarAttributeType,
};
use aws_sdk_dynamodb::{config::Region, meta::PKG_VERSION, Client, Error};
use clap::Parser;
Expand Down Expand Up @@ -47,18 +47,12 @@ async fn create_table(client: &Client) -> Result<(), Error> {
.build()
.expect("creating AttributeDefinition");

let pt = ProvisionedThroughput::builder()
.write_capacity_units(10)
.read_capacity_units(10)
.build()
.expect("creating ProvisionedThroughput");

let new_table = client
.create_table()
.table_name("test-table")
.key_schema(ks)
.attribute_definitions(ad)
.provisioned_throughput(pt)
.billing_mode(BillingMode::PayPerRequest)
.send()
.await?;
println!(
Expand Down
12 changes: 3 additions & 9 deletions rustv1/examples/dynamodb/src/bin/partiql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use aws_sdk_dynamodb::error::SdkError;
use aws_sdk_dynamodb::operation::create_table::CreateTableError;
use aws_sdk_dynamodb::operation::execute_statement::ExecuteStatementError;
use aws_sdk_dynamodb::types::{
AttributeDefinition, AttributeValue, KeySchemaElement, KeyType, ProvisionedThroughput,
AttributeDefinition, AttributeValue, BillingMode, KeySchemaElement, KeyType,
ScalarAttributeType, TableStatus,
};
use aws_sdk_dynamodb::{config::Region, meta::PKG_VERSION, Client, Error};
Expand Down Expand Up @@ -44,7 +44,7 @@ fn random_string(n: usize) -> String {
.collect()
}

/// Create a new table.
/// Create a new on-demand table.
// snippet-start:[dynamodb.rust.partiql-make_table]
async fn make_table(
client: &Client,
Expand All @@ -63,18 +63,12 @@ async fn make_table(
.build()
.expect("creating KeySchemaElement");

let pt = ProvisionedThroughput::builder()
.read_capacity_units(10)
.write_capacity_units(5)
.build()
.expect("creating ProvisionedThroughput");

match client
.create_table()
.table_name(table)
.key_schema(ks)
.attribute_definitions(ad)
.provisioned_throughput(pt)
.billing_mode(BillingMode::PayPerRequest)
.send()
.await
{
Expand Down
12 changes: 3 additions & 9 deletions rustv1/examples/dynamodb/src/scenario/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
use crate::scenario::error::Error;
use aws_sdk_dynamodb::operation::create_table::CreateTableOutput;
use aws_sdk_dynamodb::types::{
AttributeDefinition, KeySchemaElement, KeyType, ProvisionedThroughput, ScalarAttributeType,
AttributeDefinition, BillingMode, KeySchemaElement, KeyType, ScalarAttributeType,
};
use aws_sdk_dynamodb::Client;

// Create a table.
// Create an on-demand table.
// snippet-start:[dynamodb.rust.create-table]
pub async fn create_table(
client: &Client,
Expand All @@ -30,18 +30,12 @@ pub async fn create_table(
.build()
.map_err(Error::BuildError)?;

let pt = ProvisionedThroughput::builder()
.read_capacity_units(10)
.write_capacity_units(5)
.build()
.map_err(Error::BuildError)?;

let create_table_response = client
.create_table()
.table_name(table_name)
.key_schema(ks)
.attribute_definitions(ad)
.provisioned_throughput(pt)
.billing_mode(BillingMode::PayPerRequest)
.send()
.await;

Expand Down
19 changes: 5 additions & 14 deletions rustv1/examples/dynamodb/src/scenario/movies/startup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,15 @@ use crate::scenario::error::Error;
use aws_sdk_dynamodb::{
operation::create_table::builders::CreateTableFluentBuilder,
types::{
AttributeDefinition, KeySchemaElement, KeyType, ProvisionedThroughput, ScalarAttributeType,
TableStatus, WriteRequest,
AttributeDefinition, KeySchemaElement, KeyType, ScalarAttributeType, TableStatus,
WriteRequest,
},
Client,
};
use futures::future::join_all;
use std::{collections::HashMap, time::Duration};
use tracing::{debug, info, trace};

const CAPACITY: i64 = 10;

#[tracing::instrument(level = "trace")]
pub async fn initialize(client: &Client, table_name: &str) -> Result<(), Error> {
info!("Initializing Movies DynamoDB in {table_name}");
Expand All @@ -24,7 +22,7 @@ pub async fn initialize(client: &Client, table_name: &str) -> Result<(), Error>
info!("Found existing table {table_name}");
} else {
info!("Table does not exist, creating {table_name}");
create_table(client, table_name, "year", "title", CAPACITY)?
create_table(client, table_name, "year", "title")?
.send()
.await?;
await_table(client, table_name).await?;
Expand Down Expand Up @@ -55,9 +53,8 @@ pub fn create_table(
table_name: &str,
primary_key: &str,
sort_key: &str,
capacity: i64,
) -> Result<CreateTableFluentBuilder, Error> {
info!("Creating table: {table_name} with capacity {capacity} and key structure {primary_key}:{sort_key}");
info!("Creating table: {table_name} key structure {primary_key}:{sort_key}");
Ok(client
.create_table()
.table_name(table_name)
Expand Down Expand Up @@ -89,13 +86,7 @@ pub fn create_table(
.build()
.expect("Failed to build attribute definition"),
)
.provisioned_throughput(
ProvisionedThroughput::builder()
.read_capacity_units(capacity)
.write_capacity_units(capacity)
.build()
.expect("Failed to specify ProvisionedThroughput"),
))
.billing_mode(aws_sdk_dynamodb::types::BillingMode::PayPerRequest))
}
// snippet-end:[dynamodb.rust.movies-create_table_request]

Expand Down
Loading