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

main.tf#L6
resource "aws_timestreamwrite_table" "silos_data_table" {
  database_name = aws_timestreamwrite_database.timestream_db.database_name

  table_name = var.table_name

  retention_properties {
timestream.tf#L5
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
timestream.tf#L5
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
main.tf#L5
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

Review your Terraform file for AWS best practices

Shisho Cloud, our free checker to make sure your Terraform configuration follows best practices, is available (beta).

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 and memory_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 provider default_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 - The table_name and database_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 provider default_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

cf_iottotimestream.yaml#L8
    Type: 'AWS::Timestream::Table'
    Properties:
      DatabaseName: !Ref TimestreamDataBase
      TableName: "IotTimestreamTable"
      RetentionProperties:
        MemoryStoreRetentionPeriodInHours: '24'
template.yaml#L72
    Type: AWS::Timestream::Table
    Properties:
      DatabaseName: !Ref Database
      RetentionProperties:
        MemoryStoreRetentionPeriodInHours: "24"
        MagneticStoreRetentionPeriodInDays: "7"
template.yaml#L213
    Type: AWS::Timestream::Table
    Properties:
      TableName: !Sub ${AWS::StackName}LoRaWANTelemetryTable
      DatabaseName:
        Ref: TimestreamDatabase
      RetentionProperties:
cfn-application.yaml#L21
  #   Type: AWS::Timestream::Table
  #   Properties:
  #     DatabaseName: !Ref TSDBName
  #     TableName: !Ref TSTableName
  #     # RetentionProperties: Json

main.yaml#L111
    Type: AWS::Timestream::Table
    Properties:
      DatabaseName: !Ref TimeStreamDatabase
      RetentionProperties:
        MemoryStoreRetentionPeriodInHours: "24"
        MagneticStoreRetentionPeriodInDays: "7"
serverless-state.json#L292
            "Type": "AWS::Timestream::Table",
            "DependsOn": [
              "TimeStreamDBStockData"
            ],
            "Properties": {
              "TableName": "StockDataTable",
cfn-iot-rule-to-timestream.json#L10
      "Type" : "AWS::Timestream::Table",
      "Properties" : {
          "DatabaseName" : {"Ref": "TimestreamDataBase"},
          "RetentionProperties" : {
            "MemoryStoreRetentionPeriodInHours" : "24",
            "MagneticStoreRetentionPeriodInDays" : "5"
cfn-iot-rule-to-timestream.json#L10
      "Type" : "AWS::Timestream::Table",
      "Properties" : {
          "DatabaseName" : {"Ref": "TimestreamDataBase"},
          "RetentionProperties" : {
            "MemoryStoreRetentionPeriodInHours" : "24",
            "MagneticStoreRetentionPeriodInDays" : "5"
cfn-iot-rule-to-timestream.json#L10
      "Type" : "AWS::Timestream::Table",
      "Properties" : {
          "DatabaseName" : {"Ref": "TimestreamDataBase"},
          "RetentionProperties" : {
            "MemoryStoreRetentionPeriodInHours" : "24",
            "MagneticStoreRetentionPeriodInDays" : "5"
cfn-iot-rule-to-timestream.json#L10
      "Type" : "AWS::Timestream::Table",
      "Properties" : {
          "DatabaseName" : {"Ref": "TimestreamDataBase"},
          "RetentionProperties" : {
            "MemoryStoreRetentionPeriodInHours" : "24",
            "MagneticStoreRetentionPeriodInDays" : "5"

Parameters

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.