AWS DynamoDB Table Item
This page shows how to write Terraform and CloudFormation for DynamoDB Table Item and write them securely.
aws_dynamodb_table_item (Terraform)
The Table Item in DynamoDB can be configured in Terraform with the resource name aws_dynamodb_table_item
. The following sections describe 2 examples of how to use the resource and its parameters.
Example Usage from GitHub
resource "aws_dynamodb_table_item" "hotel1" {
table_name = aws_dynamodb_table.hotels.name
hash_key = aws_dynamodb_table.hotels.hash_key
item = <<ITEM
{
resource "aws_dynamodb_table_item" "dynamodb_prod_data_account_01" {
table_name = aws_dynamodb_table.dynamodb_account_prod.name
hash_key = aws_dynamodb_table.dynamodb_account_prod.hash_key
item = data.template_file.dynamo_data_account_01.rendered
}
Parameters
-
hash_key
required - string -
id
optional computed - string -
item
required - string -
range_key
optional - string -
table_name
required - string
Explanation in Terraform Registry
Provides a DynamoDB table item resource -> Note: This resource is not meant to be used for managing large amounts of data in your table, it is not designed to scale. You should perform regular backups of all data in the table, see AWS docs for more.
Tips: Best Practices for The Other AWS DynamoDB Resources
In addition to the aws_dynamodb_table, AWS DynamoDB has the other resources that should be configured for security reasons. Please check some examples of those resources and precautions.
aws_dynamodb_table
Ensure to enable point-in-time recovery of DynamoDB table
It is better to enable point-in-time recovery of DynamoDB table. It may help you restore data that is modified or deleted maliciously or accidentally.
AWS::DynamoDB::Table AttributeDefinition (CloudFormation)
The Table AttributeDefinition in DynamoDB can be configured in CloudFormation with the resource name AWS::DynamoDB::Table AttributeDefinition
. The following sections describe how to use the resource and its parameters.
Example Usage from GitHub
An example could not be found in GitHub.
Parameters
AttributeName
A name for the attribute.
Required: Yes
Type: String
Minimum: 1
Maximum: 255
Update requires: No interruption
AttributeType
The data type for the attribute, where:
S
- the attribute is of type StringN
- the attribute is of type NumberB
- the attribute is of type Binary Required: Yes
Type: String
Allowed values:B | N | S
Update requires: No interruption
Explanation in CloudFormation Registry
Represents an attribute for describing the key schema for the table and indexes.
Frequently asked questions
What is AWS DynamoDB Table Item?
AWS DynamoDB Table Item is a resource for DynamoDB of Amazon Web Service. Settings can be wrote in Terraform and CloudFormation.
Where can I find the example code for the AWS DynamoDB Table Item?
For Terraform, the hromovyi/meetup-xray-demo and aumoraes/safra-tecnee-invest-plus-iac source code examples are useful. See the Terraform Example section for further details.