1. Time-Series Forecasting for Demand Planning on AWS Timestream


    Time-Series Forecasting for Demand Planning involves capturing temporal data and leveraging statistical models to predict future demand based on past trends. On AWS, Amazon Timestream is a perfect service for this task, offering a fast, scalable, fully managed time series database. Below is a guide on how you can create a Timestream database and table using Pulumi, which can then be used for demand planning applications.

    Before we begin writing the program, let's understand the resources we will use:

    1. aws.timestreamwrite.Database: This resource is used to create a Timestream database where your time-series data will be stored. A database is a logical group of tables in Timestream.

    2. aws.timestreamwrite.Table: Inside the database, we create tables to hold actual time-series records. Each table has a retention policy for how long data should be kept in the memory store and magnetic store.

    Let's build the Pulumi program step by step:

    1. Create a new Timestream database.
    2. Create a table within the database, defining its schema and retention properties.
    3. Optionally, adjust the retention policies to fit your use case.

    Here's the Python code to accomplish those steps:

    import pulumi import pulumi_aws as aws # Create a new Timestream database named 'DemandPlanningDatabase'. timestream_database = aws.timestreamwrite.Database("DemandPlanningDatabase", database_name="demand_planning_db" ) # Now, create a Timestream table within our database. # We will call this 'DemandForecastTable'. It stores data in memory for quick access for one day # and in the magnetic store for cost-effective storage for 365 days. timestream_table = aws.timestreamwrite.Table("DemandForecastTable", database_name=timestream_database.database_name, retention_properties={ "memoryStoreRetentionPeriodInHours": "24", "magneticStoreRetentionPeriodInDays": "365" }, table_name="demand_forecast_table" ) # Export the names of the database and table so that they can be easily retrieved later. pulumi.export("database_name", timestream_database.database_name) pulumi.export("table_name", timestream_table.table_name)

    In this program, we're creating the Timestream database and table utilizing Pulumi's AWS package. We're specifying the database and table names, which could be any string that conforms to AWS's naming rules.

    The retention_properties for the table define the period for storing the data in the in-memory store for fast access (24 hours) and in the magnetic store for long-term cost-effective storage (365 days). You may change these values based on how frequently you access the data and how long you need to retain it.

    These retention periods are especially useful for demand forecasting, where you might need to access recent data quickly for short-term analysis while also keeping historical data for longer-term trend analysis.

    Finally, we are using pulumi.export to output the names of the database and table, which confirms the resources have been created and allows you to reference these outputs elsewhere in your Pulumi stack or in other Pulumi programs.

    This provided structure will be the foundation for your time-series data ingestion and can be built upon with data ingestion pipelines, query layers, and integrations with forecasting models and other AWS services.