update_table
async
¶
update_table(
table_name: TableArn,
*,
config_overrides: Optional[AsyncDynamoDBClientConfig] = 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,
disassociation_protection_enabled: Optional[DisassociationProtectionEnabled] = None,
vector_index_updates: Optional[VectorIndexUpdateList] = None,
) -> UpdateTableOutput
Modifies the provisioned throughput settings, global secondary indexes, DynamoDB Streams settings, or global table replica 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
UpdateTableto perform other operations. -
Enable or disable disassociation protection for the local global table replica.
-
Disassociate the local global table replica and keep it as a standalone regional table. The
Disassociateaction must be the only replica update in the request. If the request includes any other update,UpdateTablefails with aValidationExceptionand the disassociation does not start.
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. Use DescribeTable to monitor the table's status.
To use this operation to disassociate a local replica, you must have the dynamodb:UpdateTable and dynamodb:DisassociateTableReplica IAM permissions on the local replica. Send disassociation and disassociation protection requests to the replica's Region using credentials for the account that owns the replica. For prerequisites and the procedure, see Disassociating a global table replica in the Amazon DynamoDB Developer Guide.
To confirm successful disassociation, call DescribeTable in the replica's Region and verify that TableStatus is ACTIVE and Replicas is absent or empty. If TableStatus returns to ACTIVE but the response still includes a Replicas list, the disassociation did not complete. Check ReplicaStatus for a replication-permission or encryption-access problem, resolve it, and retry.
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,
AttributeDefinitionsmust 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 usingPAY_PER_REQUESTfor most DynamoDB workloads.PAY_PER_REQUESTsets the billing mode to On-demand capacity mode. -
PROVISIONED- We recommend usingPROVISIONEDfor steady workloads with predictable growth where capacity requirements can be reliably forecasted.PROVISIONEDsets 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
UpdateTableoperation.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
ValidationExceptionif 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, update, or disassociate) for the table.
-
table_class(Optional[TableClass], default:None) –The table class of the table to be updated. Valid values are
STANDARDandSTANDARD_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
UpdateTableoperation.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.
-
-
disassociation_protection_enabled(Optional[DisassociationProtectionEnabled], default:None) –Specifies whether disassociation protection is enabled (
true) or disabled (false) for the local replica of a multi-Region eventual consistency (MREC) global table using Version 2019.11.21.Disassociation protection is enabled by default. If you omit this parameter, the existing setting is unchanged. This setting is independent of
DeletionProtectionEnabled.You can't combine this change with any other change in the same
UpdateTablerequest. -
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
UpdateTableoperation.To add a vector index, specify
IndexName,VectorAttribute,Dimensions,DistanceFunction, andProjection. To remove a vector index, specify only theIndexName.
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, andRestoreTableToPointInTime.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
CREATINGstate. -
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.
Examples:
To modify a table's provisioned throughput This example increases the provisioned read and write capacity on the Music table.
>>> await client.update_table(provisioned_throughput={'ReadCapacityUnits': 10, 'WriteCapacityUnits': 10}, table_name='MusicCollection')
To disable disassociation protection on a local replica
This example disables disassociation protection on the MusicCollection replica in us-west-2. You must send the request to us-west-2 using credentials for the account that owns the replica. Your table must be a global table that uses Version 2019.11.21 and multi-Region eventual consistency (MREC). You cannot combine this change with any other change in the same UpdateTable request. Before requesting disassociation, use DescribeTable to confirm that DisassociationProtectionEnabled is false and TableStatus is ACTIVE.
>>> await client.update_table(table_name='MusicCollection', disassociation_protection_enabled=False)
To disassociate a local global table replica
This example disassociates the MusicCollection replica in us-west-2. You must first disable protection in a separate UpdateTable request. You must send the request to us-west-2 using credentials for account 123456789012, the account that owns the replica. This request works for global tables that use Version 2019.11.21 and multi-Region eventual consistency (MREC). Replicas can belong to one account or multiple accounts. You must specify WAIT_FOR_REPLICATION. The response shows that DynamoDB accepted the asynchronous request. To confirm completion, use DescribeTable in us-west-2. Verify that TableStatus is ACTIVE and Replicas is absent or empty. ACTIVE alone does not confirm successful disassociation.
>>> await client.update_table(table_name='arn:aws:dynamodb:us-west-2:123456789012:table/MusicCollection', replica_updates=[{'Disassociate': {'RegionName': 'us-west-2', 'DisassociationMode': 'WAIT_FOR_REPLICATION'}}])
Source code in docs_src/capo_dynamodb/_services/async_dynamo_db.py
4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 | |