Select your cookie preferences

We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics, so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can choose “Customize” or “Decline” to decline performance cookies.

If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To accept or decline all non-essential cookies, choose “Accept” or “Decline.” To make more detailed choices, choose “Customize.”

Use DescribeTimeToLive with an AWS SDK or CLI

Focus mode
Use DescribeTimeToLive with an AWS SDK or CLI - AWS SDK Code Examples

There are more AWS SDK examples available in the AWS Doc SDK Examples GitHub repo.

There are more AWS SDK examples available in the AWS Doc SDK Examples GitHub repo.

The following code examples show how to use DescribeTimeToLive.

CLI
AWS CLI

To view Time to Live settings for a table

The following describe-time-to-live example displays Time to Live settings for the MusicCollection table.

aws dynamodb describe-time-to-live \ --table-name MusicCollection

Output:

{ "TimeToLiveDescription": { "TimeToLiveStatus": "ENABLED", "AttributeName": "ttl" } }

For more information, see Time to Live in the Amazon DynamoDB Developer Guide.

Java
SDK for Java 2.x

Describe TTL configuration on an existing DynamoDB table using AWS SDK for Java 2.x.

import software.amazon.awssdk.regions.Region; import software.amazon.awssdk.services.dynamodb.DynamoDbClient; import software.amazon.awssdk.services.dynamodb.model.DescribeTimeToLiveRequest; import software.amazon.awssdk.services.dynamodb.model.DescribeTimeToLiveResponse; import software.amazon.awssdk.services.dynamodb.model.DynamoDbException; import software.amazon.awssdk.services.dynamodb.model.ResourceNotFoundException; import java.util.logging.Level; import java.util.logging.Logger; public DescribeTimeToLiveResponse describeTTL(final String tableName, final Region region) { final DescribeTimeToLiveRequest request = DescribeTimeToLiveRequest.builder().tableName(tableName).build(); try (DynamoDbClient ddb = dynamoDbClient != null ? dynamoDbClient : DynamoDbClient.builder().region(region).build()) { return ddb.describeTimeToLive(request); } catch (ResourceNotFoundException e) { System.err.format(TABLE_NOT_FOUND_ERROR, tableName); throw e; } catch (DynamoDbException e) { System.err.println(e.getMessage()); throw e; } }
JavaScript
SDK for JavaScript (v3)

Describe TTL configuration on an existing DynamoDB table using AWS SDK for JavaScript.

import { DynamoDBClient, DescribeTimeToLiveCommand } from "@aws-sdk/client-dynamodb"; export const describeTTL = async (tableName, region) => { const client = new DynamoDBClient({ region: region, endpoint: `https://dynamodb.${region}.amazonaws.com` }); try { const ttlDescription = await client.send(new DescribeTimeToLiveCommand({ TableName: tableName })); if (ttlDescription.TimeToLiveDescription.TimeToLiveStatus === 'ENABLED') { console.log("TTL is enabled for table %s.", tableName); } else { console.log("TTL is not enabled for table %s.", tableName); } return ttlDescription; } catch (e) { console.error(`Error describing table: ${e}`); throw e; } } // Example usage (commented out for testing) // describeTTL('your-table-name', 'us-east-1');
Python
SDK for Python (Boto3)

Describe TTL configuration on an existing DynamoDB table using AWS SDK for Python (Boto3).

import boto3 def describe_ttl(table_name, region): """ Describes TTL on an existing table, as well as a region. :param table_name: String representing the name of the table :param region: AWS Region of the table - example `us-east-1` :return: Time to live description. """ try: dynamodb = boto3.resource("dynamodb", region_name=region) ttl_description = dynamodb.describe_time_to_live(TableName=table_name) print( f"TimeToLive for table {table_name} is status {ttl_description['TimeToLiveDescription']['TimeToLiveStatus']}" ) return ttl_description except Exception as e: print(f"Error describing table: {e}") raise # Enter your own table name and AWS region describe_ttl("your-table-name", "us-east-1")
AWS CLI

To view Time to Live settings for a table

The following describe-time-to-live example displays Time to Live settings for the MusicCollection table.

aws dynamodb describe-time-to-live \ --table-name MusicCollection

Output:

{ "TimeToLiveDescription": { "TimeToLiveStatus": "ENABLED", "AttributeName": "ttl" } }

For more information, see Time to Live in the Amazon DynamoDB Developer Guide.

PrivacySite termsCookie preferences
© 2025, Amazon Web Services, Inc. or its affiliates. All rights reserved.