tables
Creates, updates, deletes or gets a table resource or lists tables in a region
Overview
| Name | tables |
| Type | Resource |
| Description | The You should be aware of the following behaviors when working with DDB tables: |
| Id | awscc.dynamodb.tables |
Fields
- get (all properties)
- list (identifiers only)
| Name | Datatype | Description |
|---|---|---|
on_demand_throughput | object | Sets the maximum number of read and write units for the specified on-demand table. If you use this property, you must specify MaxReadRequestUnits, MaxWriteRequestUnits, or both. |
sse_specification | object | Specifies the settings to enable server-side encryption. |
kinesis_stream_specification | object | The Kinesis Data Streams configuration for the specified table. |
stream_specification | object | The settings for the DDB table stream, which capture changes to items stored in the table. |
contributor_insights_specification | object | The settings used to enable or disable CloudWatch Contributor Insights for the specified table. |
import_source_specification | object | Specifies the properties of data being imported from the S3 bucket source to the" table.If you specify theImportSourceSpecification property, and also specify either the StreamSpecification, the TableClass property, the DeletionProtectionEnabled property, or the WarmThroughput property, the IAM entity creating/updating stack must have UpdateTable permission. |
point_in_time_recovery_specification | object | The settings used to enable point in time recovery. |
provisioned_throughput | object | Throughput for the specified table, which consists of values for If you set |
warm_throughput | object | Represents the warm throughput (in read units per second and write units per second) for creating a table. |
table_name | string | A name for the table. If you don't specify a name, CFNlong generates a unique physical ID and uses that ID for the table name. For more information, see Name Type.If you specify a name, you cannot perform updates that require replacement of this resource. You can perform updates that require no or some interruption. If you must replace the resource, specify a new name. |
attribute_definitions | array | A list of attributes that describe the key schema for the table and indexes.This property is required to create a DDB table.Update requires: Some interruptions. Replacement if you edit an existing AttributeDefinition. |
billing_mode | string | Specify how you are charged for read and write throughput and how you manage capacity.Valid values include:+ 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.If not specified, the default is PROVISIONED. |
global_secondary_indexes | array | Global secondary indexes to be created on the table. You can create up to 20 global secondary indexes.If you update a table to include a new global secondary index, CFNlong initiates the index creation and then proceeds with the stack update. CFNlong doesn't wait for the index to complete creation because the backfilling phase can take a long time, depending on the size of the table. You can't use the index or update the table until the index's status isACTIVE. You can track its status by using the DynamoDB DescribeTable command.If you add or delete an index during an update, we recommend that you don't update any other resources. If your stack fails to update and is rolled back while adding a new index, you must manually delete the index. Updates are not supported. The following are exceptions: + If you update either the contributor insights specification or the provisioned throughput values of global secondary indexes, you can update the table without interruption. + You can delete or add one global secondary index without interruption. If you do both in the same update (for example, by changing the index's logical ID), the update fails. |
resource_policy | object | An AWS resource-based policy document in JSON format that will be attached to the table.When you attach a resource-based policy while creating a table, the policy application is strongly consistent.The maximum size supported for a resource-based policy document is 20 KB. DynamoDB counts whitespaces when calculating the size of a policy against this limit. For a full list of all considerations that apply for resource-based policies, see Resource-based policy considerations. You need to specify the CreateTable and PutResourcePolicy IAM actions for authorizing a user to create a table with a resource-based policy. |
key_schema | object | Specifies the attributes that make up the primary key for the table. The attributes in the KeySchema property must also be defined in the AttributeDefinitions property. |
local_secondary_indexes | array | Local secondary indexes to be created on the table. You can create up to 5 local secondary indexes. Each index is scoped to a given hash key value. The size of each hash key can be up to 10 gigabytes. |
arn | string | |
stream_arn | string | |
deletion_protection_enabled | boolean | Determines if a table is protected from deletion. When enabled, the table cannot be deleted by any user or process. This setting is disabled by default. For more information, see Using deletion protection in the Developer Guide. |
table_class | string | The table class of the new table. Valid values are STANDARD and STANDARD_INFREQUENT_ACCESS. |
tags | array | An array of key-value pairs to apply to this resource.For more information, see Tag. |
time_to_live_specification | object | Specifies the Time to Live (TTL) settings for the table.For detailed information about the limits in DynamoDB, see Limits in Amazon DynamoDB in the Amazon DynamoDB Developer Guide. |
region | string | AWS region. |
| Name | Datatype | Description |
|---|---|---|
table_name | string | A name for the table. If you don't specify a name, CFNlong generates a unique physical ID and uses that ID for the table name. For more information, see Name Type.If you specify a name, you cannot perform updates that require replacement of this resource. You can perform updates that require no or some interruption. If you must replace the resource, specify a new name. |
region | string | AWS region. |
For more information, see AWS::DynamoDB::Table.
Methods
| Name | Resource | Accessible by | Required Params |
|---|---|---|---|
create_resource | tables | INSERT | KeySchema, region |
delete_resource | tables | DELETE | Identifier, region |
update_resource | tables | UPDATE | Identifier, PatchDocument, region |
list_resources | tables_list_only | SELECT | region |
get_resource | tables | SELECT | Identifier, region |
SELECT examples
- get (all properties)
- list (identifiers only)
Gets all properties from an individual table.
SELECT
region,
on_demand_throughput,
sse_specification,
kinesis_stream_specification,
stream_specification,
contributor_insights_specification,
import_source_specification,
point_in_time_recovery_specification,
provisioned_throughput,
warm_throughput,
table_name,
attribute_definitions,
billing_mode,
global_secondary_indexes,
resource_policy,
key_schema,
local_secondary_indexes,
arn,
stream_arn,
deletion_protection_enabled,
table_class,
tags,
time_to_live_specification
FROM awscc.dynamodb.tables
WHERE
region = '{{ region }}' AND
Identifier = '{{ table_name }}';
Lists all tables in a region.
SELECT
region,
table_name
FROM awscc.dynamodb.tables_list_only
WHERE
region = '{{ region }}';
INSERT example
Use the following StackQL query and manifest file to create a new table resource, using stack-deploy.
- Required Properties
- All Properties
- Manifest
/*+ create */
INSERT INTO awscc.dynamodb.tables (
KeySchema,
region
)
SELECT
'{{ key_schema }}',
'{{ region }}'
RETURNING
ErrorCode,
EventTime,
Identifier,
Operation,
OperationStatus,
RequestToken,
ResourceModel,
RetryAfter,
StatusMessage,
TypeName
;
/*+ create */
INSERT INTO awscc.dynamodb.tables (
OnDemandThroughput,
SSESpecification,
KinesisStreamSpecification,
StreamSpecification,
ContributorInsightsSpecification,
ImportSourceSpecification,
PointInTimeRecoverySpecification,
ProvisionedThroughput,
WarmThroughput,
TableName,
AttributeDefinitions,
BillingMode,
GlobalSecondaryIndexes,
ResourcePolicy,
KeySchema,
LocalSecondaryIndexes,
DeletionProtectionEnabled,
TableClass,
Tags,
TimeToLiveSpecification,
region
)
SELECT
'{{ on_demand_throughput }}',
'{{ sse_specification }}',
'{{ kinesis_stream_specification }}',
'{{ stream_specification }}',
'{{ contributor_insights_specification }}',
'{{ import_source_specification }}',
'{{ point_in_time_recovery_specification }}',
'{{ provisioned_throughput }}',
'{{ warm_throughput }}',
'{{ table_name }}',
'{{ attribute_definitions }}',
'{{ billing_mode }}',
'{{ global_secondary_indexes }}',
'{{ resource_policy }}',
'{{ key_schema }}',
'{{ local_secondary_indexes }}',
'{{ deletion_protection_enabled }}',
'{{ table_class }}',
'{{ tags }}',
'{{ time_to_live_specification }}',
'{{ region }}'
RETURNING
ErrorCode,
EventTime,
Identifier,
Operation,
OperationStatus,
RequestToken,
ResourceModel,
RetryAfter,
StatusMessage,
TypeName
;
version: 1
name: stack name
description: stack description
providers:
- aws
globals:
- name: region
value: '{{ vars.AWS_REGION }}'
resources:
- name: table
props:
- name: on_demand_throughput
value:
max_read_request_units: '{{ max_read_request_units }}'
max_write_request_units: '{{ max_write_request_units }}'
- name: sse_specification
value:
sse_enabled: '{{ sse_enabled }}'
sse_type: '{{ sse_type }}'
kms_master_key_id: '{{ kms_master_key_id }}'
- name: kinesis_stream_specification
value:
approximate_creation_date_time_precision: '{{ approximate_creation_date_time_precision }}'
stream_arn: '{{ stream_arn }}'
- name: stream_specification
value:
stream_view_type: '{{ stream_view_type }}'
resource_policy:
policy_document: {}
- name: contributor_insights_specification
value:
mode: '{{ mode }}'
enabled: '{{ enabled }}'
- name: import_source_specification
value:
s3_bucket_source:
s3_bucket: '{{ s3_bucket }}'
s3_key_prefix: '{{ s3_key_prefix }}'
s3_bucket_owner: '{{ s3_bucket_owner }}'
input_format: '{{ input_format }}'
input_format_options:
csv:
delimiter: '{{ delimiter }}'
header_list:
- '{{ header_list[0] }}'
input_compression_type: '{{ input_compression_type }}'
- name: point_in_time_recovery_specification
value:
point_in_time_recovery_enabled: '{{ point_in_time_recovery_enabled }}'
recovery_period_in_days: '{{ recovery_period_in_days }}'
- name: provisioned_throughput
value:
write_capacity_units: '{{ write_capacity_units }}'
read_capacity_units: '{{ read_capacity_units }}'
- name: warm_throughput
value:
read_units_per_second: '{{ read_units_per_second }}'
write_units_per_second: '{{ write_units_per_second }}'
- name: table_name
value: '{{ table_name }}'
- name: attribute_definitions
value:
- attribute_type: '{{ attribute_type }}'
attribute_name: '{{ attribute_name }}'
- name: billing_mode
value: '{{ billing_mode }}'
- name: global_secondary_indexes
value:
- index_name: '{{ index_name }}'
on_demand_throughput: null
contributor_insights_specification: null
projection:
non_key_attributes:
- '{{ non_key_attributes[0] }}'
projection_type: '{{ projection_type }}'
provisioned_throughput: null
key_schema:
- key_type: '{{ key_type }}'
attribute_name: '{{ attribute_name }}'
warm_throughput: null
- name: resource_policy
value: null
- name: key_schema
value: null
- name: local_secondary_indexes
value:
- index_name: '{{ index_name }}'
projection: null
key_schema:
- null
- name: deletion_protection_enabled
value: '{{ deletion_protection_enabled }}'
- name: table_class
value: '{{ table_class }}'
- name: tags
value:
- value: '{{ value }}'
key: '{{ key }}'
- name: time_to_live_specification
value:
enabled: '{{ enabled }}'
attribute_name: '{{ attribute_name }}'
UPDATE example
Use the following StackQL query and manifest file to update a table resource, using stack-deploy.
/*+ update */
UPDATE awscc.dynamodb.tables
SET PatchDocument = string('{{ {
"OnDemandThroughput": on_demand_throughput,
"SSESpecification": sse_specification,
"KinesisStreamSpecification": kinesis_stream_specification,
"StreamSpecification": stream_specification,
"ContributorInsightsSpecification": contributor_insights_specification,
"PointInTimeRecoverySpecification": point_in_time_recovery_specification,
"ProvisionedThroughput": provisioned_throughput,
"WarmThroughput": warm_throughput,
"AttributeDefinitions": attribute_definitions,
"BillingMode": billing_mode,
"GlobalSecondaryIndexes": global_secondary_indexes,
"ResourcePolicy": resource_policy,
"KeySchema": key_schema,
"LocalSecondaryIndexes": local_secondary_indexes,
"DeletionProtectionEnabled": deletion_protection_enabled,
"TableClass": table_class,
"Tags": tags,
"TimeToLiveSpecification": time_to_live_specification
} | generate_patch_document }}')
WHERE
region = '{{ region }}' AND
Identifier = '{{ table_name }}'
RETURNING
ErrorCode,
EventTime,
Identifier,
Operation,
OperationStatus,
RequestToken,
ResourceModel,
RetryAfter,
StatusMessage,
TypeName
;
DELETE example
/*+ delete */
DELETE FROM awscc.dynamodb.tables
WHERE
Identifier = '{{ table_name }}' AND
region = '{{ region }}'
RETURNING
ErrorCode,
EventTime,
Identifier,
Operation,
OperationStatus,
RequestToken,
ResourceModel,
RetryAfter,
StatusMessage,
TypeName
;
Additional Parameters
Mutable resources in the Cloud Control provider support additional optional parameters which can be supplied with INSERT, UPDATE, or DELETE operations. These include:
| Parameter | Description |
|---|---|
ClientToken | A unique identifier to ensure the idempotency of the resource request.This allows the provider to accurately distinguish between retries and new requests.A client token is valid for 36 hours once used. After that, a resource request with the same client token is treated as a new request. If you do not specify a client token, one is generated for inclusion in the request. |
RoleArn | The ARN of the IAM role used to perform this resource operation.The role specified must have the permissions required for this operation.If you do not specify a role, a temporary session is created using your AWS user credentials. |
TypeVersionId | For private resource types, the type version to use in this resource operation.If you do not specify a resource version, the default version is used. |
Permissions
To operate on the tables resource, the following permissions are required:
- Read
- Create
- Update
- List
- Delete
dynamodb:DescribeTable,
dynamodb:DescribeContinuousBackups,
dynamodb:DescribeContributorInsights,
dynamodb:DescribeKinesisStreamingDestination,
dynamodb:ListTagsOfResource,
dynamodb:GetResourcePolicy
dynamodb:CreateTable,
dynamodb:DescribeImport,
dynamodb:DescribeTable,
dynamodb:DescribeTimeToLive,
dynamodb:UpdateTimeToLive,
dynamodb:UpdateContributorInsights,
dynamodb:UpdateContinuousBackups,
dynamodb:DescribeContinuousBackups,
dynamodb:DescribeContributorInsights,
dynamodb:EnableKinesisStreamingDestination,
dynamodb:DisableKinesisStreamingDestination,
dynamodb:DescribeKinesisStreamingDestination,
dynamodb:ImportTable,
dynamodb:ListTagsOfResource,
dynamodb:TagResource,
dynamodb:UpdateTable,
dynamodb:GetResourcePolicy,
dynamodb:PutResourcePolicy,
kinesis:DescribeStream,
kinesis:PutRecords,
iam:CreateServiceLinkedRole,
kms:CreateGrant,
kms:Decrypt,
kms:DescribeKey,
kms:ListAliases,
kms:Encrypt,
kms:RevokeGrant,
logs:CreateLogGroup,
logs:CreateLogStream,
logs:DescribeLogGroups,
logs:DescribeLogStreams,
logs:PutLogEvents,
logs:PutRetentionPolicy,
s3:GetObject,
s3:GetObjectMetadata,
s3:ListBucket
dynamodb:UpdateTable,
dynamodb:DescribeTable,
dynamodb:DescribeTimeToLive,
dynamodb:UpdateTimeToLive,
dynamodb:UpdateContinuousBackups,
dynamodb:UpdateContributorInsights,
dynamodb:UpdateKinesisStreamingDestination,
dynamodb:DescribeContinuousBackups,
dynamodb:DescribeKinesisStreamingDestination,
dynamodb:ListTagsOfResource,
dynamodb:TagResource,
dynamodb:UntagResource,
dynamodb:DescribeContributorInsights,
dynamodb:EnableKinesisStreamingDestination,
dynamodb:DisableKinesisStreamingDestination,
dynamodb:GetResourcePolicy,
dynamodb:PutResourcePolicy,
dynamodb:DeleteResourcePolicy,
kinesis:DescribeStream,
kinesis:PutRecords,
iam:CreateServiceLinkedRole,
kms:CreateGrant,
kms:DescribeKey,
kms:ListAliases,
kms:RevokeGrant
dynamodb:ListTables
dynamodb:DeleteTable,
dynamodb:DescribeTable