Skip to content

Commit

Permalink
feat(client-dynamodb): This change adds support for global tables wit…
Browse files Browse the repository at this point in the history
…h multi-Region strong consistency (in preview). The UpdateTable API now supports a new attribute MultiRegionConsistency to set consistency when creating global tables. The DescribeTable output now optionally includes the MultiRegionConsistency attribute.
  • Loading branch information
awstools committed Dec 3, 2024
1 parent 40ef36d commit c96da51
Show file tree
Hide file tree
Showing 13 changed files with 167 additions and 3 deletions.
1 change: 1 addition & 0 deletions clients/client-dynamodb/src/commands/CreateTableCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ export interface CreateTableCommandOutput extends CreateTableOutput, __MetadataB
* // WriteUnitsPerSecond: Number("long"),
* // Status: "CREATING" || "UPDATING" || "DELETING" || "ACTIVE" || "INACCESSIBLE_ENCRYPTION_CREDENTIALS" || "ARCHIVING" || "ARCHIVED",
* // },
* // MultiRegionConsistency: "EVENTUAL" || "STRONG",
* // },
* // };
*
Expand Down
3 changes: 3 additions & 0 deletions clients/client-dynamodb/src/commands/DeleteItemCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,9 @@ export interface DeleteItemCommandOutput extends DeleteItemOutput, __MetadataBea
* successful, unless your retry queue is too large to finish. Reduce the frequency of
* requests and use exponential backoff. For more information, go to <a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Programming.Errors.html#Programming.Errors.RetryAndBackoff">Error Retries and Exponential Backoff</a> in the <i>Amazon DynamoDB Developer Guide</i>.</p>
*
* @throws {@link ReplicatedWriteConflictException} (client fault)
* <p>The request was rejected because one or more items in the request are being modified by a request in another Region. </p>
*
* @throws {@link RequestLimitExceeded} (client fault)
* <p>Throughput exceeds the current throughput quota for your account. Please contact
* <a href="https://aws.amazon.com/support">Amazon Web Services Support</a> to request a
Expand Down
1 change: 1 addition & 0 deletions clients/client-dynamodb/src/commands/DeleteTableCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ export interface DeleteTableCommandOutput extends DeleteTableOutput, __MetadataB
* // WriteUnitsPerSecond: Number("long"),
* // Status: "CREATING" || "UPDATING" || "DELETING" || "ACTIVE" || "INACCESSIBLE_ENCRYPTION_CREDENTIALS" || "ARCHIVING" || "ARCHIVED",
* // },
* // MultiRegionConsistency: "EVENTUAL" || "STRONG",
* // },
* // };
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ export interface DescribeTableCommandOutput extends DescribeTableOutput, __Metad
* // WriteUnitsPerSecond: Number("long"),
* // Status: "CREATING" || "UPDATING" || "DELETING" || "ACTIVE" || "INACCESSIBLE_ENCRYPTION_CREDENTIALS" || "ARCHIVING" || "ARCHIVED",
* // },
* // MultiRegionConsistency: "EVENTUAL" || "STRONG",
* // },
* // };
*
Expand Down
3 changes: 3 additions & 0 deletions clients/client-dynamodb/src/commands/PutItemCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,9 @@ export interface PutItemCommandOutput extends PutItemOutput, __MetadataBearer {}
* successful, unless your retry queue is too large to finish. Reduce the frequency of
* requests and use exponential backoff. For more information, go to <a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Programming.Errors.html#Programming.Errors.RetryAndBackoff">Error Retries and Exponential Backoff</a> in the <i>Amazon DynamoDB Developer Guide</i>.</p>
*
* @throws {@link ReplicatedWriteConflictException} (client fault)
* <p>The request was rejected because one or more items in the request are being modified by a request in another Region. </p>
*
* @throws {@link RequestLimitExceeded} (client fault)
* <p>Throughput exceeds the current throughput quota for your account. Please contact
* <a href="https://aws.amazon.com/support">Amazon Web Services Support</a> to request a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ export interface RestoreTableFromBackupCommandOutput extends RestoreTableFromBac
* // WriteUnitsPerSecond: Number("long"),
* // Status: "CREATING" || "UPDATING" || "DELETING" || "ACTIVE" || "INACCESSIBLE_ENCRYPTION_CREDENTIALS" || "ARCHIVING" || "ARCHIVED",
* // },
* // MultiRegionConsistency: "EVENTUAL" || "STRONG",
* // },
* // };
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ export interface RestoreTableToPointInTimeCommandOutput extends RestoreTableToPo
* // WriteUnitsPerSecond: Number("long"),
* // Status: "CREATING" || "UPDATING" || "DELETING" || "ACTIVE" || "INACCESSIBLE_ENCRYPTION_CREDENTIALS" || "ARCHIVING" || "ARCHIVED",
* // },
* // MultiRegionConsistency: "EVENTUAL" || "STRONG",
* // },
* // };
*
Expand Down
3 changes: 3 additions & 0 deletions clients/client-dynamodb/src/commands/UpdateItemCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,9 @@ export interface UpdateItemCommandOutput extends UpdateItemOutput, __MetadataBea
* successful, unless your retry queue is too large to finish. Reduce the frequency of
* requests and use exponential backoff. For more information, go to <a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Programming.Errors.html#Programming.Errors.RetryAndBackoff">Error Retries and Exponential Backoff</a> in the <i>Amazon DynamoDB Developer Guide</i>.</p>
*
* @throws {@link ReplicatedWriteConflictException} (client fault)
* <p>The request was rejected because one or more items in the request are being modified by a request in another Region. </p>
*
* @throws {@link RequestLimitExceeded} (client fault)
* <p>Throughput exceeds the current throughput quota for your account. Please contact
* <a href="https://aws.amazon.com/support">Amazon Web Services Support</a> to request a
Expand Down
2 changes: 2 additions & 0 deletions clients/client-dynamodb/src/commands/UpdateTableCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ export interface UpdateTableCommandOutput extends UpdateTableOutput, __MetadataB
* ],
* TableClass: "STANDARD" || "STANDARD_INFREQUENT_ACCESS",
* DeletionProtectionEnabled: true || false,
* MultiRegionConsistency: "EVENTUAL" || "STRONG",
* OnDemandThroughput: {
* MaxReadRequestUnits: Number("long"),
* MaxWriteRequestUnits: Number("long"),
Expand Down Expand Up @@ -364,6 +365,7 @@ export interface UpdateTableCommandOutput extends UpdateTableOutput, __MetadataB
* // WriteUnitsPerSecond: Number("long"),
* // Status: "CREATING" || "UPDATING" || "DELETING" || "ACTIVE" || "INACCESSIBLE_ENCRYPTION_CREDENTIALS" || "ARCHIVING" || "ARCHIVED",
* // },
* // MultiRegionConsistency: "EVENTUAL" || "STRONG",
* // },
* // };
*
Expand Down
2 changes: 1 addition & 1 deletion clients/client-dynamodb/src/endpoint/ruleset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,5 @@ D=[k],
E=[l],
F=[n],
G=[o,{[J]:g,[K]:[p,"disabled"]}];
const _data={version:"1.0",parameters:{Region:i,UseDualStack:j,UseFIPS:j,Endpoint:i,AccountId:i,AccountIdEndpointMode:i},rules:[{conditions:[{[J]:b,[K]:[{[L]:"Endpoint"}]}],rules:[{conditions:D,error:"Invalid Configuration: FIPS and custom endpoint are not supported",[I]:c},{conditions:E,error:"Invalid Configuration: Dualstack and custom endpoint are not supported",[I]:c},{endpoint:{[M]:"{Endpoint}",[N]:m,[O]:m},[I]:d}],[I]:e},{conditions:[{[J]:b,[K]:F}],rules:[{conditions:[{[J]:"aws.partition",[K]:F,assign:f}],rules:[{conditions:[{[J]:g,[K]:[n,"local"]}],rules:[{conditions:D,error:"Invalid Configuration: FIPS and local endpoint are not supported",[I]:c},{conditions:E,error:"Invalid Configuration: Dualstack and local endpoint are not supported",[I]:c},{endpoint:{[M]:"http://localhost:8000",[N]:{authSchemes:[{name:"sigv4",signingName:"dynamodb",signingRegion:"us-east-1"}]},[O]:m},[I]:d}],[I]:e},{conditions:[o,{[J]:g,[K]:[p,"required"]},{[J]:h,[K]:[q]}],error:"AccountIdEndpointMode is required but no AccountID was provided or able to be loaded.",[I]:c},{conditions:[q,s,u,v,{[J]:h,[K]:[{[J]:"isValidHostLabel",[K]:[r,a]}]}],error:"Credentials-sourced account ID parameter is invalid",[I]:c},{conditions:[k,l],rules:[{conditions:[w,x],rules:[{conditions:G,endpoint:y,[I]:d},{endpoint:y,[I]:d}],[I]:e},{error:"FIPS and DualStack are enabled, but this partition does not support one or both",[I]:c}],[I]:e},{conditions:D,rules:[{conditions:[w],rules:[{conditions:[{[J]:g,[K]:[t,"aws-us-gov"]}],rules:[z,A],[I]:e},{conditions:G,endpoint:B,[I]:d},{endpoint:B,[I]:d}],[I]:e},{error:"FIPS is enabled but this partition does not support FIPS",[I]:c}],[I]:e},{conditions:E,rules:[{conditions:[x],rules:[{conditions:G,endpoint:C,[I]:d},{endpoint:C,[I]:d}],[I]:e},{error:"DualStack is enabled but this partition does not support DualStack",[I]:c}],[I]:e},z,{conditions:[q,s,u,v],endpoint:{[M]:"https://{AccountId}.ddb.{Region}.{PartitionResult#dnsSuffix}",[N]:m,[O]:m},[I]:d},A],[I]:e}],[I]:e},{error:"Invalid Configuration: Missing Region",[I]:c}]};
const _data={version:"1.0",parameters:{Region:i,UseDualStack:j,UseFIPS:j,Endpoint:i,AccountId:i,AccountIdEndpointMode:i},rules:[{conditions:[{[J]:b,[K]:[{[L]:"Endpoint"}]}],rules:[{conditions:D,error:"Invalid Configuration: FIPS and custom endpoint are not supported",[I]:c},{conditions:E,error:"Invalid Configuration: Dualstack and custom endpoint are not supported",[I]:c},{endpoint:{[M]:"{Endpoint}",[N]:m,[O]:m},[I]:d}],[I]:e},{conditions:[{[J]:b,[K]:F}],rules:[{conditions:[{[J]:"aws.partition",[K]:F,assign:f}],rules:[{conditions:[{[J]:g,[K]:[n,"local"]}],rules:[{conditions:D,error:"Invalid Configuration: FIPS and local endpoint are not supported",[I]:c},{conditions:E,error:"Invalid Configuration: Dualstack and local endpoint are not supported",[I]:c},{endpoint:{[M]:"http://localhost:8000",[N]:{authSchemes:[{signingRegion:"us-east-1",signingName:"dynamodb",name:"sigv4"}]},[O]:m},[I]:d}],[I]:e},{conditions:[o,{[J]:g,[K]:[p,"required"]},{[J]:h,[K]:[q]}],error:"AccountIdEndpointMode is required but no AccountID was provided or able to be loaded.",[I]:c},{conditions:[q,s,u,v,{[J]:h,[K]:[{[J]:"isValidHostLabel",[K]:[r,a]}]}],error:"Credentials-sourced account ID parameter is invalid",[I]:c},{conditions:[k,l],rules:[{conditions:[w,x],rules:[{conditions:G,endpoint:y,[I]:d},{endpoint:y,[I]:d}],[I]:e},{error:"FIPS and DualStack are enabled, but this partition does not support one or both",[I]:c}],[I]:e},{conditions:D,rules:[{conditions:[w],rules:[{conditions:[{[J]:g,[K]:[t,"aws-us-gov"]}],rules:[z,A],[I]:e},{conditions:G,endpoint:B,[I]:d},{endpoint:B,[I]:d}],[I]:e},{error:"FIPS is enabled but this partition does not support FIPS",[I]:c}],[I]:e},{conditions:E,rules:[{conditions:[x],rules:[{conditions:G,endpoint:C,[I]:d},{endpoint:C,[I]:d}],[I]:e},{error:"DualStack is enabled but this partition does not support DualStack",[I]:c}],[I]:e},z,{conditions:[q,s,u,v],endpoint:{[M]:"https://{AccountId}.ddb.{Region}.{PartitionResult#dnsSuffix}",[N]:m,[O]:m},[I]:d},A],[I]:e}],[I]:e},{error:"Invalid Configuration: Missing Region",[I]:c}]};
export const ruleSet: RuleSetObject = _data;
75 changes: 75 additions & 0 deletions clients/client-dynamodb/src/models/models_0.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3143,6 +3143,20 @@ export interface LocalSecondaryIndexDescription {
IndexArn?: string | undefined;
}

/**
* @public
* @enum
*/
export const MultiRegionConsistency = {
EVENTUAL: "EVENTUAL",
STRONG: "STRONG",
} as const;

/**
* @public
*/
export type MultiRegionConsistency = (typeof MultiRegionConsistency)[keyof typeof MultiRegionConsistency];

/**
* <p>Contains details for the restore.</p>
* @public
Expand Down Expand Up @@ -3612,6 +3626,26 @@ export interface TableDescription {
* @public
*/
WarmThroughput?: TableWarmThroughputDescription | undefined;

/**
* <p>Indicates one of the following consistency modes for a global table:</p>
* <ul>
* <li>
* <p>
* <code>EVENTUAL</code>: Indicates that the global table is configured for multi-Region eventual consistency.</p>
* </li>
* <li>
* <p>
* <code>STRONG</code>: Indicates that the global table is configured for multi-Region strong consistency (preview).</p>
* <note>
* <p>Multi-Region strong consistency (MRSC) is a new DynamoDB global tables capability currently available in preview mode. For more information, see <a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/PreviewFeatures.html#multi-region-strong-consistency-gt">Global tables multi-Region strong consistency</a>.</p>
* </note>
* </li>
* </ul>
* <p>If you don't specify this field, the global table consistency mode defaults to <code>EVENTUAL</code>.</p>
* @public
*/
MultiRegionConsistency?: MultiRegionConsistency | undefined;
}

/**
Expand Down Expand Up @@ -3730,6 +3764,26 @@ export const ReturnValue = {
*/
export type ReturnValue = (typeof ReturnValue)[keyof typeof ReturnValue];

/**
* <p>The request was rejected because one or more items in the request are being modified by a request in another Region. </p>
* @public
*/
export class ReplicatedWriteConflictException extends __BaseException {
readonly name: "ReplicatedWriteConflictException" = "ReplicatedWriteConflictException";
readonly $fault: "client" = "client";
/**
* @internal
*/
constructor(opts: __ExceptionOptionType<ReplicatedWriteConflictException, __BaseException>) {
super({
name: "ReplicatedWriteConflictException",
$fault: "client",
...opts,
});
Object.setPrototypeOf(this, ReplicatedWriteConflictException.prototype);
}
}

/**
* <p>Operation was rejected because there is an ongoing transaction for the
* item.</p>
Expand Down Expand Up @@ -7228,6 +7282,27 @@ export interface UpdateTableInput {
*/
DeletionProtectionEnabled?: boolean | undefined;

/**
* <p>Specifies the consistency mode for a new global table. This parameter is only valid when you create a global table by specifying one or more <a href="https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_ReplicationGroupUpdate.html#DDB-Type-ReplicationGroupUpdate-Create">Create</a> actions in the <a href="https://docs.aws.amazon.com/https:/docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_UpdateTable.html#DDB-UpdateTable-request-ReplicaUpdates">ReplicaUpdates</a> action list.</p>
* <p>You can specify one of the following consistency modes:</p>
* <ul>
* <li>
* <p>
* <code>EVENTUAL</code>: Configures a new global table for multi-Region eventual consistency. This is the default consistency mode for global tables.</p>
* </li>
* <li>
* <p>
* <code>STRONG</code>: Configures a new global table for multi-Region strong consistency (preview).</p>
* <note>
* <p>Multi-Region strong consistency (MRSC) is a new DynamoDB global tables capability currently available in preview mode. For more information, see <a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/PreviewFeatures.html#multi-region-strong-consistency-gt">Global tables multi-Region strong consistency</a>.</p>
* </note>
* </li>
* </ul>
* <p>If you don't specify this parameter, the global table consistency mode defaults to <code>EVENTUAL</code>.</p>
* @public
*/
MultiRegionConsistency?: MultiRegionConsistency | undefined;

/**
* <p>Updates the maximum number of read and write units for the specified table in
* on-demand capacity mode. If you use this parameter, you must specify
Expand Down
23 changes: 23 additions & 0 deletions clients/client-dynamodb/src/protocols/Aws_json1_0.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ import {
ReplicaNotFoundException,
ReplicaSettingsDescription,
ReplicaSettingsUpdate,
ReplicatedWriteConflictException,
ReplicationGroupUpdate,
ReplicaUpdate,
RequestLimitExceeded,
Expand Down Expand Up @@ -2289,6 +2290,9 @@ const de_CommandError = async (output: __HttpResponse, context: __SerdeContext):
case "ConditionalCheckFailedException":
case "com.amazonaws.dynamodb#ConditionalCheckFailedException":
throw await de_ConditionalCheckFailedExceptionRes(parsedOutput, context);
case "ReplicatedWriteConflictException":
case "com.amazonaws.dynamodb#ReplicatedWriteConflictException":
throw await de_ReplicatedWriteConflictExceptionRes(parsedOutput, context);
case "TransactionConflictException":
case "com.amazonaws.dynamodb#TransactionConflictException":
throw await de_TransactionConflictExceptionRes(parsedOutput, context);
Expand Down Expand Up @@ -2734,6 +2738,22 @@ const de_ReplicaNotFoundExceptionRes = async (
return __decorateServiceException(exception, body);
};

/**
* deserializeAws_json1_0ReplicatedWriteConflictExceptionRes
*/
const de_ReplicatedWriteConflictExceptionRes = async (
parsedOutput: any,
context: __SerdeContext
): Promise<ReplicatedWriteConflictException> => {
const body = parsedOutput.body;
const deserialized: any = _json(body);
const exception = new ReplicatedWriteConflictException({
$metadata: deserializeMetadata(parsedOutput),
...deserialized,
});
return __decorateServiceException(exception, body);
};

/**
* deserializeAws_json1_0RequestLimitExceededRes
*/
Expand Down Expand Up @@ -5305,6 +5325,8 @@ const de_ReplicaSettingsDescriptionList = (output: any, context: __SerdeContext)
return retVal;
};

// de_ReplicatedWriteConflictException omitted.

// de_RequestLimitExceeded omitted.

// de_ResourceInUseException omitted.
Expand Down Expand Up @@ -5460,6 +5482,7 @@ const de_TableDescription = (output: any, context: __SerdeContext): TableDescrip
LatestStreamArn: __expectString,
LatestStreamLabel: __expectString,
LocalSecondaryIndexes: _json,
MultiRegionConsistency: __expectString,
OnDemandThroughput: _json,
ProvisionedThroughput: (_: any) => de_ProvisionedThroughputDescription(_, context),
Replicas: (_: any) => de_ReplicaDescriptionList(_, context),
Expand Down
Loading

0 comments on commit c96da51

Please sign in to comment.