Skip to content

update_table

update_table(
    table_name: TableArn,
    *,
    config_overrides: Optional[DynamoDBClientConfig] = None,
    attribute_definitions: Optional[AttributeDefinitions] = None,
    billing_mode: Optional[BillingMode] = None,
    provisioned_throughput: Optional[ProvisionedThroughput] = None,
    global_secondary_index_updates: Optional[GlobalSecondaryIndexUpdateList] = None,
    stream_specification: Optional[StreamSpecification] = None,
    sse_specification: Optional[SSESpecification] = None,
    replica_updates: Optional[ReplicationGroupUpdateList] = None,
    table_class: Optional[TableClass] = None,
    deletion_protection_enabled: Optional[DeletionProtectionEnabled] = None,
    multi_region_consistency: Optional[MultiRegionConsistency] = None,
    global_table_witness_updates: Optional[GlobalTableWitnessGroupUpdateList] = None,
    on_demand_throughput: Optional[OnDemandThroughput] = None,
    warm_throughput: Optional[WarmThroughput] = None,
    global_table_settings_replication_mode: Optional[
        GlobalTableSettingsReplicationMode
    ] = None,
    vector_index_updates: Optional[VectorIndexUpdateList] = None,
) -> UpdateTableOutput

Modifies the provisioned throughput settings, global secondary indexes, or DynamoDB Streams settings for a given table.

You can only perform one of the following operations at once:

  • Modify the provisioned throughput settings of the table.

  • Remove a global secondary index from the table.

  • Create a new global secondary index on the table. After the index begins backfilling, you can use UpdateTable to perform other operations.

UpdateTable is an asynchronous operation; while it's executing, the table status changes from ACTIVE to UPDATING. While it's UPDATING, you can't issue another UpdateTable request. When the table returns to the ACTIVE state, the UpdateTable operation is complete.

Parameters:

  • attribute_definitions (Optional[AttributeDefinitions], default: None ) –

    An array of attributes that describe the key schema for the table and indexes. If you are adding a new global secondary index to the table, AttributeDefinitions must include the key element(s) of the new index.

  • table_name (TableArn) –

    The name of the table to be updated. You can also provide the Amazon Resource Name (ARN) of the table in this parameter.

  • billing_mode (Optional[BillingMode], default: None ) –

    Controls how you are charged for read and write throughput and how you manage capacity. When switching from pay-per-request to provisioned capacity, initial provisioned capacity values must be set. The initial provisioned capacity values are estimated based on the consumed read and write capacity of your table and global secondary indexes over the past 30 minutes.

    • PAY_PER_REQUEST - We recommend using PAY_PER_REQUEST for most DynamoDB workloads. PAY_PER_REQUEST sets the billing mode to On-demand capacity mode.

    • PROVISIONED - We recommend using PROVISIONED for steady workloads with predictable growth where capacity requirements can be reliably forecasted. PROVISIONED sets the billing mode to Provisioned capacity mode.

  • provisioned_throughput (Optional[ProvisionedThroughput], default: None ) –

    The new provisioned throughput settings for the specified table or index.

  • global_secondary_index_updates (Optional[GlobalSecondaryIndexUpdateList], default: None ) –

    An array of one or more global secondary indexes for the table. For each index in the array, you can request one action:

    • Create - add a new global secondary index to the table.

    • Update - modify the provisioned throughput settings of an existing global secondary index.

    • Delete - remove a global secondary index from the table.

    You can create or delete only one global secondary index per UpdateTable operation.

    For more information, see Managing Global Secondary Indexes in the Amazon DynamoDB Developer Guide.

  • stream_specification (Optional[StreamSpecification], default: None ) –

    Represents the DynamoDB Streams configuration for the table.

    You receive a ValidationException if you try to enable a stream on a table that already has a stream, or if you try to disable a stream on a table that doesn't have a stream.

  • sse_specification (Optional[SSESpecification], default: None ) –

    The new server-side encryption settings for the specified table.

  • replica_updates (Optional[ReplicationGroupUpdateList], default: None ) –

    A list of replica update actions (create, delete, or update) for the table.

  • table_class (Optional[TableClass], default: None ) –

    The table class of the table to be updated. Valid values are STANDARD and STANDARD_INFREQUENT_ACCESS.

  • deletion_protection_enabled (Optional[DeletionProtectionEnabled], default: None ) –

    Indicates whether deletion protection is to be enabled (true) or disabled (false) on the table.

  • multi_region_consistency (Optional[MultiRegionConsistency], default: None ) –

    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 Create actions in the ReplicaUpdates action list.

    You can specify one of the following consistency modes:

    • EVENTUAL: Configures a new global table for multi-Region eventual consistency (MREC). This is the default consistency mode for global tables.

    • STRONG: Configures a new global table for multi-Region strong consistency (MRSC).

    If you don't specify this field, the global table consistency mode defaults to EVENTUAL. For more information about global tables consistency modes, see Consistency modes in DynamoDB developer guide.

  • global_table_witness_updates (Optional[GlobalTableWitnessGroupUpdateList], default: None ) –

    A list of witness updates for a MRSC global table. A witness provides a cost-effective alternative to a full replica in a MRSC global table by maintaining replicated change data written to global table replicas. You cannot perform read or write operations on a witness. For each witness, you can request one action:

    • Create - add a new witness to the global table.

    • Delete - remove a witness from the global table.

    You can create or delete only one witness per UpdateTable operation.

    For more information, see Multi-Region strong consistency (MRSC) in the Amazon DynamoDB Developer Guide

  • on_demand_throughput (Optional[OnDemandThroughput], default: None ) –

    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 MaxReadRequestUnits, MaxWriteRequestUnits, or both.

  • warm_throughput (Optional[WarmThroughput], default: None ) –

    Represents the warm throughput (in read units per second and write units per second) for updating a table.

  • global_table_settings_replication_mode (Optional[GlobalTableSettingsReplicationMode], default: None ) –

    Controls the settings replication mode for a global table replica. This attribute can be defined using UpdateTable operation only on a regional table with values:

    • ENABLED: Defines settings replication on a regional table to be used as a source table for creating Multi-Account Global Table.

    • DISABLED: Remove settings replication on a regional table. Settings replication needs to be defined to ENABLED again in order to create a Multi-Account Global Table using this table.

  • vector_index_updates (Optional[VectorIndexUpdateList], default: None ) –

    A list of vector indexes to be added to or removed from the table. You can add or remove one vector index for each UpdateTable operation.

    To add a vector index, specify IndexName, VectorAttribute, Dimensions, DistanceFunction, and Projection. To remove a vector index, specify only the IndexName.

Raises:

  • InternalServerError –

    An error occurred on the server side.

  • LimitExceededException –

    There is no limit to the number of daily on-demand backups that can be taken.

    For most purposes, up to 500 simultaneous table operations are allowed per account. These operations include CreateTable, UpdateTable, DeleteTable,UpdateTimeToLive, RestoreTableFromBackup, and RestoreTableToPointInTime.

    When you are creating a table with one or more secondary indexes, you can have up to 250 such requests running at a time. However, if the table or index specifications are complex, then DynamoDB might temporarily reduce the number of concurrent operations.

    When importing into DynamoDB, up to 50 simultaneous import table operations are allowed per account.

    There is a soft account quota of 2,500 tables.

    GetRecords was called with a value of more than 1000 for the limit request parameter.

    More than 2 processes are reading from the same streams shard at the same time. Exceeding this limit may result in request throttling.

  • ResourceInUseException –

    The operation conflicts with the resource's availability. For example:

    • You attempted to recreate an existing table.

    • You tried to delete a table currently in the CREATING state.

    • You tried to update a resource that was already being updated.

    When appropriate, wait for the ongoing update to complete and attempt the request again.

  • ResourceNotFoundException –

    The operation tried to access a nonexistent table or index. The resource might not be specified correctly, or its status might not be ACTIVE.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_dynamodb/_services/dynamo_db.py
def update_table(
    self,
    table_name: "capo_dynamodb.types.table_arn.TableArn",
    *,
    config_overrides: Optional[DynamoDBClientConfig] = None,
    attribute_definitions: Optional[
        "capo_dynamodb.types.attribute_definitions.AttributeDefinitions"
    ] = None,
    billing_mode: Optional["capo_dynamodb.types.billing_mode.BillingMode"] = None,
    provisioned_throughput: Optional[
        "capo_dynamodb.types.provisioned_throughput.ProvisionedThroughput"
    ] = None,
    global_secondary_index_updates: Optional[
        "capo_dynamodb.types.global_secondary_index_update_list.GlobalSecondaryIndexUpdateList"
    ] = None,
    stream_specification: Optional[
        "capo_dynamodb.types.stream_specification.StreamSpecification"
    ] = None,
    sse_specification: Optional[
        "capo_dynamodb.types.sse_specification.SSESpecification"
    ] = None,
    replica_updates: Optional[
        "capo_dynamodb.types.replication_group_update_list.ReplicationGroupUpdateList"
    ] = None,
    table_class: Optional["capo_dynamodb.types.table_class.TableClass"] = None,
    deletion_protection_enabled: Optional[
        "capo_dynamodb.types.deletion_protection_enabled.DeletionProtectionEnabled"
    ] = None,
    multi_region_consistency: Optional[
        "capo_dynamodb.types.multi_region_consistency.MultiRegionConsistency"
    ] = None,
    global_table_witness_updates: Optional[
        "capo_dynamodb.types.global_table_witness_group_update_list.GlobalTableWitnessGroupUpdateList"
    ] = None,
    on_demand_throughput: Optional[
        "capo_dynamodb.types.on_demand_throughput.OnDemandThroughput"
    ] = None,
    warm_throughput: Optional[
        "capo_dynamodb.types.warm_throughput.WarmThroughput"
    ] = None,
    global_table_settings_replication_mode: Optional[
        "capo_dynamodb.types.global_table_settings_replication_mode.GlobalTableSettingsReplicationMode"
    ] = None,
    vector_index_updates: Optional[
        "capo_dynamodb.types.vector_index_update_list.VectorIndexUpdateList"
    ] = None,
) -> "capo_dynamodb.types.update_table_output.UpdateTableOutput":
    """<p>Modifies the provisioned throughput settings, global secondary indexes, or DynamoDB Streams settings for a given table.</p> <p>You can only perform one of the following operations at once:</p> <ul> <li> <p>Modify the provisioned throughput settings of the table.</p> </li> <li> <p>Remove a global secondary index from the table.</p> </li> <li> <p>Create a new global secondary index on the table. After the index begins backfilling, you can use <code>UpdateTable</code> to perform other operations.</p> </li> </ul> <p> <code>UpdateTable</code> is an asynchronous operation; while it's executing, the table status changes from <code>ACTIVE</code> to <code>UPDATING</code>. While it's <code>UPDATING</code>, you can't issue another <code>UpdateTable</code> request. When the table returns to the <code>ACTIVE</code> state, the <code>UpdateTable</code> operation is complete.</p>

    Args:
        attribute_definitions: <p>An array of attributes that describe the key schema for the table and indexes. If you are adding a new global secondary index to the table, <code>AttributeDefinitions</code> must include the key element(s) of the new index.</p>
        table_name: <p>The name of the table to be updated. You can also provide the Amazon Resource Name (ARN) of the table in this parameter.</p>
        billing_mode: <p>Controls how you are charged for read and write throughput and how you manage capacity. When switching from pay-per-request to provisioned capacity, initial provisioned capacity values must be set. The initial provisioned capacity values are estimated based on the consumed read and write capacity of your table and global secondary indexes over the past 30 minutes.</p> <ul> <li> <p> <code>PAY_PER_REQUEST</code> - We recommend using <code>PAY_PER_REQUEST</code> for most DynamoDB workloads. <code>PAY_PER_REQUEST</code> sets the billing mode to <a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/on-demand-capacity-mode.html">On-demand capacity mode</a>. </p> </li> <li> <p> <code>PROVISIONED</code> - We recommend using <code>PROVISIONED</code> for steady workloads with predictable growth where capacity requirements can be reliably forecasted. <code>PROVISIONED</code> sets the billing mode to <a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/provisioned-capacity-mode.html">Provisioned capacity mode</a>.</p> </li> </ul>
        provisioned_throughput: <p>The new provisioned throughput settings for the specified table or index.</p>
        global_secondary_index_updates: <p>An array of one or more global secondary indexes for the table. For each index in the array, you can request one action:</p> <ul> <li> <p> <code>Create</code> - add a new global secondary index to the table.</p> </li> <li> <p> <code>Update</code> - modify the provisioned throughput settings of an existing global secondary index.</p> </li> <li> <p> <code>Delete</code> - remove a global secondary index from the table.</p> </li> </ul> <p>You can create or delete only one global secondary index per <code>UpdateTable</code> operation.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/GSI.OnlineOps.html">Managing Global Secondary Indexes</a> in the <i>Amazon DynamoDB Developer Guide</i>. </p>
        stream_specification: <p>Represents the DynamoDB Streams configuration for the table.</p> <note> <p>You receive a <code>ValidationException</code> if you try to enable a stream on a table that already has a stream, or if you try to disable a stream on a table that doesn't have a stream.</p> </note>
        sse_specification: <p>The new server-side encryption settings for the specified table.</p>
        replica_updates: <p>A list of replica update actions (create, delete, or update) for the table.</p>
        table_class: <p>The table class of the table to be updated. Valid values are <code>STANDARD</code> and <code>STANDARD_INFREQUENT_ACCESS</code>.</p>
        deletion_protection_enabled: <p>Indicates whether deletion protection is to be enabled (true) or disabled (false) on the table.</p>
        multi_region_consistency: <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/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 (MREC). 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 (MRSC).</p> </li> </ul> <p>If you don't specify this field, the global table consistency mode defaults to <code>EVENTUAL</code>. For more information about global tables consistency modes, see <a href="https://docs.aws.amazon.com/V2globaltables_HowItWorks.html#V2globaltables_HowItWorks.consistency-modes"> Consistency modes</a> in DynamoDB developer guide. </p>
        global_table_witness_updates: <p>A list of witness updates for a MRSC global table. A witness provides a cost-effective alternative to a full replica in a MRSC global table by maintaining replicated change data written to global table replicas. You cannot perform read or write operations on a witness. For each witness, you can request one action:</p> <ul> <li> <p> <code>Create</code> - add a new witness to the global table.</p> </li> <li> <p> <code>Delete</code> - remove a witness from the global table.</p> </li> </ul> <p>You can create or delete only one witness per <code>UpdateTable</code> operation.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/V2globaltables_HowItWorks.html#V2globaltables_HowItWorks.consistency-modes">Multi-Region strong consistency (MRSC)</a> in the Amazon DynamoDB Developer Guide</p>
        on_demand_throughput: <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 <code>MaxReadRequestUnits</code>, <code>MaxWriteRequestUnits</code>, or both.</p>
        warm_throughput: <p>Represents the warm throughput (in read units per second and write units per second) for updating a table.</p>
        global_table_settings_replication_mode: <p>Controls the settings replication mode for a global table replica. This attribute can be defined using UpdateTable operation only on a regional table with values:</p> <ul> <li> <p> <code>ENABLED</code>: Defines settings replication on a regional table to be used as a source table for creating Multi-Account Global Table.</p> </li> <li> <p> <code>DISABLED</code>: Remove settings replication on a regional table. Settings replication needs to be defined to ENABLED again in order to create a Multi-Account Global Table using this table. </p> </li> </ul>
        vector_index_updates: <p>A list of vector indexes to be added to or removed from the table. You can add or remove one vector index for each <code>UpdateTable</code> operation.</p> <p>To add a vector index, specify <code>IndexName</code>, <code>VectorAttribute</code>, <code>Dimensions</code>, <code>DistanceFunction</code>, and <code>Projection</code>. To remove a vector index, specify only the <code>IndexName</code>.</p>

    Raises:
        capo_dynamodb.errors.internal_server_error.InternalServerError: <p>An error occurred on the server side.</p>
        capo_dynamodb.errors.invalid_endpoint_exception.InvalidEndpointException
        capo_dynamodb.errors.limit_exceeded_exception.LimitExceededException: <p>There is no limit to the number of daily on-demand backups that can be taken. </p> <p>For most purposes, up to 500 simultaneous table operations are allowed per account. These operations include <code>CreateTable</code>, <code>UpdateTable</code>, <code>DeleteTable</code>,<code>UpdateTimeToLive</code>, <code>RestoreTableFromBackup</code>, and <code>RestoreTableToPointInTime</code>. </p> <p>When you are creating a table with one or more secondary indexes, you can have up to 250 such requests running at a time. However, if the table or index specifications are complex, then DynamoDB might temporarily reduce the number of concurrent operations.</p> <p>When importing into DynamoDB, up to 50 simultaneous import table operations are allowed per account.</p> <p>There is a soft account quota of 2,500 tables.</p> <p>GetRecords was called with a value of more than 1000 for the limit request parameter.</p> <p>More than 2 processes are reading from the same streams shard at the same time. Exceeding this limit may result in request throttling.</p>
        capo_dynamodb.errors.resource_in_use_exception.ResourceInUseException: <p>The operation conflicts with the resource's availability. For example:</p> <ul> <li> <p>You attempted to recreate an existing table.</p> </li> <li> <p>You tried to delete a table currently in the <code>CREATING</code> state.</p> </li> <li> <p>You tried to update a resource that was already being updated.</p> </li> </ul> <p>When appropriate, wait for the ongoing update to complete and attempt the request again.</p>
        capo_dynamodb.errors.resource_not_found_exception.ResourceNotFoundException: <p>The operation tried to access a nonexistent table or index. The resource might not be specified correctly, or its status might not be <code>ACTIVE</code>.</p>
        capo_dynamodb.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_dynamodb.types.update_table_input.UpdateTableInput]",
    ) -> OperationResponse[
        "capo_dynamodb.types.update_table_output.UpdateTableOutput"
    ]:
        import capo_dynamodb._operations.dynamo_db_20120810.update_table

        output, http_response = (
            capo_dynamodb._operations.dynamo_db_20120810.update_table.update_table(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("UpdateTable")
    )
    input_: capo_dynamodb.types.update_table_input.UpdateTableInput = {
        "table_name": table_name
    }
    if attribute_definitions is not None:
        input_["attribute_definitions"] = attribute_definitions
    if billing_mode is not None:
        input_["billing_mode"] = billing_mode
    if provisioned_throughput is not None:
        input_["provisioned_throughput"] = provisioned_throughput
    if global_secondary_index_updates is not None:
        input_["global_secondary_index_updates"] = global_secondary_index_updates
    if stream_specification is not None:
        input_["stream_specification"] = stream_specification
    if sse_specification is not None:
        input_["sse_specification"] = sse_specification
    if replica_updates is not None:
        input_["replica_updates"] = replica_updates
    if table_class is not None:
        input_["table_class"] = table_class
    if deletion_protection_enabled is not None:
        input_["deletion_protection_enabled"] = deletion_protection_enabled
    if multi_region_consistency is not None:
        input_["multi_region_consistency"] = multi_region_consistency
    if global_table_witness_updates is not None:
        input_["global_table_witness_updates"] = global_table_witness_updates
    if on_demand_throughput is not None:
        input_["on_demand_throughput"] = on_demand_throughput
    if warm_throughput is not None:
        input_["warm_throughput"] = warm_throughput
    if global_table_settings_replication_mode is not None:
        input_["global_table_settings_replication_mode"] = (
            global_table_settings_replication_mode
        )
    if vector_index_updates is not None:
        input_["vector_index_updates"] = vector_index_updates

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output