1. Using AWS Timestream for enterprise time-series data

    TypeScript

    To leverage AWS Timestream for time-series data, you'll first need to create a TimeStream database, and then tables within that database for your time-series data.

    Now, let's build out your infrastructure as code step-by-step.

    Step 1: Create a Timestream database

    A timestreamwrite.Database resource can be used to create an Amazon Timestream database. The databaseName property defines the name of the database.

    import * as aws from "@pulumi/aws"; const example = new aws.timestreamwrite.Database("example", {databaseName: "example"});

    In this code, example is used as both the name of the Pulumi resource and the databaseName in AWS Timestream.

    Step 2: Create a Timestream table

    After creating a database, a timestreamwrite.Table resource is used to create a table within the database. The databaseName property of this resource should match the databaseName of the timestreamwrite.Database resource. The tableName property defines the name of the table.

    import * as aws from "@pulumi/aws"; const example = new aws.timestreamwrite.Database("example", {databaseName: "example"}); const table = new aws.timestreamwrite.Table("table", { databaseName: example.databaseName, tableName: "table", });

    In this code, table is used as the name of the Pulumi resource and also as the tableName in AWS Timestream.

    Final Program:

    Here's your completed Pulumi program that accomplishes your goal. It creates a Timestream database and a table within that database.

    import * as pulumi from "@pulumi/pulumi"; import * as aws from "@pulumi/aws"; const config = new pulumi.Config(); const awsRegion = config.require("aws:region"); // Create a Timestream database const exampleDatabase = new aws.timestreamwrite.Database("exampleDatabase", { databaseName: "exampleDatabase", }); // Create a table in the Timestream database const exampleTable = new aws.timestreamwrite.Table("exampleTable", { databaseName: exampleDatabase.databaseName, tableName: "exampleTable", retentionProperties: { memoryStoreRetentionPeriodInHours: 24, magneticStoreRetentionPeriodInDays: 7 } }); // Export the ARN of the table export const tableArn = exampleTable.arn;

    To run this program, save it to a file, and run pulumi up. Your new Timestream database and table will be created and the table's ARN will be printed on successful completion.