Class Table
java.lang.Object
software.amazon.jsii.JsiiObject
software.constructs.Construct
software.amazon.awscdk.Resource
software.amazon.awscdk.services.dynamodb.TableBase
software.amazon.awscdk.services.dynamodb.Table
- All Implemented Interfaces:
IResource,ITable,software.amazon.jsii.JsiiSerializable,software.constructs.IConstruct,software.constructs.IDependable
@Generated(value="jsii-pacmak/1.93.0 (build 1706ca5)",
date="2024-01-03T18:29:24.870Z")
@Stability(Stable)
public class Table
extends TableBase
Provides a DynamoDB table.
Example:
import software.amazon.awscdk.services.dynamodb.*;
// create a table
Table table = Table.Builder.create(this, "montable")
.partitionKey(Attribute.builder()
.name("id")
.type(AttributeType.STRING)
.build())
.build();
Pass finalStatus = new Pass(this, "final step");
// States language JSON to put an item into DynamoDB
// snippet generated from https://docs.aws.amazon.com/step-functions/latest/dg/tutorial-code-snippet.html#tutorial-code-snippet-1
Map<String, Object> stateJson = Map.of(
"Type", "Task",
"Resource", "arn:aws:states:::dynamodb:putItem",
"Parameters", Map.of(
"TableName", table.getTableName(),
"Item", Map.of(
"id", Map.of(
"S", "MyEntry"))),
"ResultPath", null);
// custom state which represents a task to insert data into DynamoDB
CustomState custom = CustomState.Builder.create(this, "my custom task")
.stateJson(stateJson)
.build();
// catch errors with addCatch
Pass errorHandler = new Pass(this, "handle failure");
custom.addCatch(errorHandler);
Chain chain = Chain.start(custom).next(finalStatus);
StateMachine sm = StateMachine.Builder.create(this, "StateMachine")
.definitionBody(DefinitionBody.fromChainable(chain))
.timeout(Duration.seconds(30))
.comment("a super cool state machine")
.build();
// don't forget permissions. You need to assign them
table.grantWriteData(sm);
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationModeNested classes/interfaces inherited from interface software.constructs.IConstruct
software.constructs.IConstruct.Jsii$DefaultNested classes/interfaces inherited from interface software.amazon.awscdk.IResource
IResource.Jsii$DefaultNested classes/interfaces inherited from interface software.amazon.awscdk.services.dynamodb.ITable
ITable.Jsii$Default -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedTable(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protectedTable(software.amazon.jsii.JsiiObjectRef objRef) Table(software.constructs.Construct scope, String id, TableProps props) -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a global secondary index of table.voidAdd a local secondary index of table.autoScaleGlobalSecondaryIndexReadCapacity(String indexName, EnableScalingProps props) Enable read capacity scaling for the given GSI.autoScaleGlobalSecondaryIndexWriteCapacity(String indexName, EnableScalingProps props) Enable write capacity scaling for the given GSI.Enable read capacity scaling for this table.Enable write capacity scaling for this table.static ITablefromTableArn(software.constructs.Construct scope, String id, String tableArn) Creates a Table construct that represents an external table via table arn.static ITablefromTableAttributes(software.constructs.Construct scope, String id, TableAttributes attrs) Creates a Table construct that represents an external table.static ITablefromTableName(software.constructs.Construct scope, String id, String tableName) Creates a Table construct that represents an external table via table name.KMS encryption key, if this table uses a customer-managed encryption key.protected BooleanWhether this table has indexes.Arn of the dynamodb table.Table name of the dynamodb table.ARN of the table's stream, if there is one.schema()Get schema attributes of table or index.Get schema attributes of table or index.Methods inherited from class software.amazon.awscdk.services.dynamodb.TableBase
getRegionalArns, grant, grantFullAccess, grantReadData, grantReadWriteData, grantStream, grantStreamRead, grantTableListStreams, grantWriteData, metric, metric, metricConditionalCheckFailedRequests, metricConditionalCheckFailedRequests, metricConsumedReadCapacityUnits, metricConsumedReadCapacityUnits, metricConsumedWriteCapacityUnits, metricConsumedWriteCapacityUnits, metricSuccessfulRequestLatency, metricSuccessfulRequestLatency, metricSystemErrors, metricSystemErrors, metricSystemErrorsForOperations, metricSystemErrorsForOperations, metricThrottledRequests, metricThrottledRequests, metricThrottledRequestsForOperation, metricThrottledRequestsForOperation, metricThrottledRequestsForOperations, metricThrottledRequestsForOperations, metricUserErrors, metricUserErrorsMethods inherited from class software.amazon.awscdk.Resource
applyRemovalPolicy, generatePhysicalName, getEnv, getPhysicalName, getResourceArnAttribute, getResourceNameAttribute, getStack, isOwnedResource, isResourceMethods inherited from class software.constructs.Construct
getNode, isConstruct, toStringMethods inherited from class software.amazon.jsii.JsiiObject
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSetMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface software.constructs.IConstruct
getNodeMethods inherited from interface software.amazon.awscdk.IResource
applyRemovalPolicy, getEnv, getStackMethods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Constructor Details
-
Table
protected Table(software.amazon.jsii.JsiiObjectRef objRef) -
Table
protected Table(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) -
Table
@Stability(Stable) public Table(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull TableProps props) - Parameters:
scope- This parameter is required.id- This parameter is required.props- This parameter is required.
-
-
Method Details
-
fromTableArn
@Stability(Stable) @NotNull public static ITable fromTableArn(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull String tableArn) Creates a Table construct that represents an external table via table arn.- Parameters:
scope- The parent creating construct (usuallythis). This parameter is required.id- The construct's name. This parameter is required.tableArn- The table's ARN. This parameter is required.
-
fromTableAttributes
@Stability(Stable) @NotNull public static ITable fromTableAttributes(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull TableAttributes attrs) Creates a Table construct that represents an external table.- Parameters:
scope- The parent creating construct (usuallythis). This parameter is required.id- The construct's name. This parameter is required.attrs- ATableAttributesobject. This parameter is required.
-
fromTableName
@Stability(Stable) @NotNull public static ITable fromTableName(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull String tableName) Creates a Table construct that represents an external table via table name.- Parameters:
scope- The parent creating construct (usuallythis). This parameter is required.id- The construct's name. This parameter is required.tableName- The table's name. This parameter is required.
-
addGlobalSecondaryIndex
Add a global secondary index of table.- Parameters:
props- the property of global secondary index. This parameter is required.
-
addLocalSecondaryIndex
Add a local secondary index of table.- Parameters:
props- the property of local secondary index. This parameter is required.
-
autoScaleGlobalSecondaryIndexReadCapacity
@Stability(Stable) @NotNull public IScalableTableAttribute autoScaleGlobalSecondaryIndexReadCapacity(@NotNull String indexName, @NotNull EnableScalingProps props) Enable read capacity scaling for the given GSI.- Parameters:
indexName- This parameter is required.props- This parameter is required.- Returns:
- An object to configure additional AutoScaling settings for this attribute
-
autoScaleGlobalSecondaryIndexWriteCapacity
@Stability(Stable) @NotNull public IScalableTableAttribute autoScaleGlobalSecondaryIndexWriteCapacity(@NotNull String indexName, @NotNull EnableScalingProps props) Enable write capacity scaling for the given GSI.- Parameters:
indexName- This parameter is required.props- This parameter is required.- Returns:
- An object to configure additional AutoScaling settings for this attribute
-
autoScaleReadCapacity
@Stability(Stable) @NotNull public IScalableTableAttribute autoScaleReadCapacity(@NotNull EnableScalingProps props) Enable read capacity scaling for this table.- Parameters:
props- This parameter is required.- Returns:
- An object to configure additional AutoScaling settings
-
autoScaleWriteCapacity
@Stability(Stable) @NotNull public IScalableTableAttribute autoScaleWriteCapacity(@NotNull EnableScalingProps props) Enable write capacity scaling for this table.- Parameters:
props- This parameter is required.- Returns:
- An object to configure additional AutoScaling settings for this attribute
-
schema
Get schema attributes of table or index.- Parameters:
indexName-- Returns:
- Schema of table or index.
-
schema
Get schema attributes of table or index.- Returns:
- Schema of table or index.
-
getHasIndex
Whether this table has indexes.- Specified by:
getHasIndexin classTableBase
-
getTableArn
Arn of the dynamodb table.- Specified by:
getTableArnin interfaceITable- Specified by:
getTableArnin classTableBase
-
getTableName
Table name of the dynamodb table.- Specified by:
getTableNamein interfaceITable- Specified by:
getTableNamein classTableBase
-
getEncryptionKey
KMS encryption key, if this table uses a customer-managed encryption key.- Specified by:
getEncryptionKeyin interfaceITable- Specified by:
getEncryptionKeyin classTableBase
-
getTableStreamArn
ARN of the table's stream, if there is one.- Specified by:
getTableStreamArnin interfaceITable- Specified by:
getTableStreamArnin classTableBase
-