Created
November 25, 2018 20:06
-
-
Save jkielbaey/a560c2d9fc77dd0aaa73622d2010d216 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import boto3 | |
table_name = ‘sample_table’ | |
ssm = boto3.client('ssm') | |
table = boto3.resource('dynamodb').Table(table_name) | |
# Store current read and write capacity units. | |
ssm.put_parameter( | |
Name=’/dynamodb/{}/read_capacity_units’.format(table_name), | |
Value=str(table.provisioned_throughput[‘ReadCapacityUnits’]), | |
Type='String', | |
Overwrite=True, | |
) | |
ssm.put_parameter( | |
Name=’/dynamodb/{}/write_capacity_units’.format(table_name), | |
Value=str(table.provisioned_throughput[‘WriteCapacityUnits’]), | |
Type='String', | |
Overwrite=True, | |
) | |
# Stop table. | |
table = table.update( | |
ProvisionedThroughput={ | |
'ReadCapacityUnits': 0, | |
'WriteCapacityUnits': 0 | |
}) | |
# Fetch read and write capacity units. | |
response = ssm.get_parameter( | |
Name=’/dynamodb/{}/read_capacity_units’.format(table_name) | |
) | |
read_capacity_units = response[‘Parameter’][‘Value’] | |
response = ssm.get_parameter( | |
Name=’/dynamodb/{}/write_capacity_units’.format(table_name) | |
) | |
write_capacity_units = response[‘Parameter’][‘Value’] | |
table = table.update( | |
ProvisionedThroughput={ | |
'ReadCapacityUnits': read_capacity_units, | |
'WriteCapacityUnits': write_capacity_units | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment