AWS Amazon Timestream Table
This page shows how to write Terraform and CloudFormation for Amazon Timestream Table and write them securely.
aws_timestreamwrite_table (Terraform)
The Table in Amazon Timestream can be configured in Terraform with the resource name aws_timestreamwrite_table
. The following sections describe 4 examples of how to use the resource and its parameters.
Example Usage from GitHub
resource "aws_timestreamwrite_table" "silos_data_table" {
database_name = aws_timestreamwrite_database.timestream_db.database_name
table_name = var.table_name
retention_properties {
resource "aws_timestreamwrite_table" "example" {
database_name = aws_timestreamwrite_database.example.database_name
table_name = "sensorData2"
retention_properties {
magnetic_store_retention_period_in_days = 7
resource "aws_timestreamwrite_table" "sample" {
database_name = aws_timestreamwrite_database.sample.database_name
table_name = "SampleTable"
retention_properties {
magnetic_store_retention_period_in_days = 30
resource "aws_timestreamwrite_table" "redirects" {
database_name = aws_timestreamwrite_database.this.database_name
table_name = "redirects"
retention_properties {
magnetic_store_retention_period_in_days = 90
Parameters
The following arguments are supported:
database_name
– (Required) The name of the Timestream database.retention_properties
- (Optional) The retention duration for the memory store and magnetic store. See Retention Properties below for more details. If not provided,magnetic_store_retention_period_in_days
default to 73000 andmemory_store_retention_period_in_hours
defaults to 6.table_name
- (Required) The name of the Timestream table.tags
- (Optional) Map of tags to assign to this resource. If configured with a providerdefault_tags
configuration block present, tags with matching keys will overwrite those defined at the provider-level.
Retention Properties
The retention_properties
block supports the following arguments:
magnetic_store_retention_period_in_days
- (Required) The duration for which data must be stored in the magnetic store. Minimum value of 1. Maximum value of 73000.memory_store_retention_period_in_hours
- (Required) The duration for which data must be stored in the memory store. Minimum value of 1. Maximum value of 8766.
In addition to all arguments above, the following attributes are exported:
id
- Thetable_name
anddatabase_name
separated by a colon (:
).arn
- The ARN that uniquely identifies this table.tags_all
- A map of tags assigned to the resource, including those inherited from the providerdefault_tags
configuration block.
Explanation in Terraform Registry
Provides a Timestream table resource.
AWS::Timestream::Table (CloudFormation)
The Table in Timestream can be configured in CloudFormation with the resource name AWS::Timestream::Table
. The following sections describe 10 examples of how to use the resource and its parameters.
Example Usage from GitHub
Type: 'AWS::Timestream::Table'
Properties:
DatabaseName: !Ref TimestreamDataBase
TableName: "IotTimestreamTable"
RetentionProperties:
MemoryStoreRetentionPeriodInHours: '24'
Type: AWS::Timestream::Table
Properties:
DatabaseName: !Ref Database
RetentionProperties:
MemoryStoreRetentionPeriodInHours: "24"
MagneticStoreRetentionPeriodInDays: "7"
Type: AWS::Timestream::Table
Properties:
TableName: !Sub ${AWS::StackName}LoRaWANTelemetryTable
DatabaseName:
Ref: TimestreamDatabase
RetentionProperties:
# Type: AWS::Timestream::Table
# Properties:
# DatabaseName: !Ref TSDBName
# TableName: !Ref TSTableName
# # RetentionProperties: Json
Type: AWS::Timestream::Table
Properties:
DatabaseName: !Ref TimeStreamDatabase
RetentionProperties:
MemoryStoreRetentionPeriodInHours: "24"
MagneticStoreRetentionPeriodInDays: "7"
"Type": "AWS::Timestream::Table",
"DependsOn": [
"TimeStreamDBStockData"
],
"Properties": {
"TableName": "StockDataTable",
"Type" : "AWS::Timestream::Table",
"Properties" : {
"DatabaseName" : {"Ref": "TimestreamDataBase"},
"RetentionProperties" : {
"MemoryStoreRetentionPeriodInHours" : "24",
"MagneticStoreRetentionPeriodInDays" : "5"
"Type" : "AWS::Timestream::Table",
"Properties" : {
"DatabaseName" : {"Ref": "TimestreamDataBase"},
"RetentionProperties" : {
"MemoryStoreRetentionPeriodInHours" : "24",
"MagneticStoreRetentionPeriodInDays" : "5"
"Type" : "AWS::Timestream::Table",
"Properties" : {
"DatabaseName" : {"Ref": "TimestreamDataBase"},
"RetentionProperties" : {
"MemoryStoreRetentionPeriodInHours" : "24",
"MagneticStoreRetentionPeriodInDays" : "5"
"Type" : "AWS::Timestream::Table",
"Properties" : {
"DatabaseName" : {"Ref": "TimestreamDataBase"},
"RetentionProperties" : {
"MemoryStoreRetentionPeriodInHours" : "24",
"MagneticStoreRetentionPeriodInDays" : "5"
Parameters
-
DatabaseName
required - String -
TableName
optional - String -
RetentionProperties
optional - Json -
Tags
optional - List of Tag
Explanation in CloudFormation Registry
The CreateTable operation adds a new table to an existing database in your account. In an AWS account, table names must be at least unique within each Region if they are in the same database. You may have identical table names in the same Region if the tables are in separate databases. While creating the table, you must specify the table name, database name, and the retention properties. Service quotas apply. See code sample for details.
Frequently asked questions
What is AWS Amazon Timestream Table?
AWS Amazon Timestream Table is a resource for Amazon Timestream of Amazon Web Service. Settings can be wrote in Terraform and CloudFormation.
Where can I find the example code for the AWS Amazon Timestream Table?
For Terraform, the 10kloud/infrastructure, joeypiccola/homelab and Jimon-s/terraform-example-timestream source code examples are useful. See the Terraform Example section for further details.
For CloudFormation, the aws-samples/generate-notification-from-amazon-timestream, JoshArmi/tf2eventbridge and aws-samples/aws-iot-core-lorawan source code examples are useful. See the CloudFormation Example section for further details.