Create Sample Data

Create Sample Data

In this step, we will configure Kinesis Data Generator (KDG) to generate sample data and push it to Amazon Data Firehose. KDG is a web-based tool that simplifies sending test data to Kinesis streams/Firehose.

The Kinesis Data Generator requires an Amazon Cognito user pool for authentication. We will deploy a CloudFormation stack to automatically set up Cognito and generate the KDG login URL.

Configure Amazon Cognito for Kinesis Data Generator

  1. Access the AWS Management Console.

    • Find CloudFormation.
    • Select CloudFormation.

    Search CloudFormation

  2. In the CloudFormation interface.

    • Choose Stacks.
    • Choose Create stack.
    • Select With new resources (standard).

    Create Stack

  3. Download the cognito-setup.yaml file from First Cloud AI Journey.

    • Use the shortcut Ctrl + S to Save it.
  4. In the Create stack interface.

    • Choose Choose an existing template.
    • Choose Upload a template file.
    • Choose Choose file.
    • Select cognito-setup.yaml.
    • Choose Next.

    Upload Template

  5. In the Specify stack details interface.

    • Stack name, enter Kinesis-Data-Generator-Cognito-User.
    • Configure the Kinesis Data Generator Cognito Configuration Parameters:
      • Create demo Cognito user, select true.
      • Demo username, enter kdguser.
      • Demo password, enter the password you want to use.
    • Choose Next.

    Specify Stack Details

  6. In the Configure stack options interface.

    • Check I acknowledge that AWS CloudFormation might create IAM resources.
    • Choose Next.

    Acknowledge IAM

  7. In the Review and create interface.

    • Review the stack creation options.
    • Choose Submit.

    Submit Stack

  8. Wait for about 3 minutes to complete the stack creation.

    • Select the Kinesis-Data-Generator-Cognito-User stack.
    • Choose Events to view the initialization process.
    • Status will show CREATE_IN_PROGRESS.

    Stack Creating

  9. After the stack is created successfully.

    • The status will change to CREATE_COMPLETE.
    • You can view the Latest deployment timeline.

    Stack Created

  10. In the Stack interface.

    • Select the Kinesis-Data-Generator-Cognito-User stack.
    • Choose Outputs.
    • Find the KinesisDataGeneratorUrl and click the URL.

    Outputs KDG URL

  11. In the Amazon Kinesis Data Generator interface.

    • Enter Username: kdguser.
    • Enter Password.
    • Choose Sign In.

    KDG Sign In

  12. If the Kinesis Data Generator shows an error about configuration, go back to CloudFormation Outputs tab.

    • Copy the UserPoolClientId and UserPoolId values.

    Outputs Details

  13. Scroll up in the Outputs tab to see all 6 output values.

    • Note the IdentityPoolId, KinesisDataGeneratorUrl, and other values.

    Full Outputs

  14. In the Amazon Kinesis Data Generator, click Configure.

    • Enter the Cognito configuration values from the CloudFormation Outputs.
    • Click Save Changes.

    KDG Configure

  15. After successful configuration and login.

    • Region, select the region where you created the Delivery stream (e.g., ap-southeast-1).
    • Stream/delivery stream, select your Firehose stream.
    • Records per second, enter 2000.
    • Choose Template 1.

    KDG Setup

  16. Enter the following code in the Template 1 editor:

    {
      "uuid": "{{random.uuid}}",
      "device_ts": "{{date.utc("YYYY-MM-DD HH:mm:ss.SSS")}}",
      "device_id": {{random.number(50)}},
      "device_temp": {{random.weightedArrayElement(
        {"weights":[0.30, 0.30, 0.20, 0.20],"data":[32, 34, 28, 40]}
      )}},
      "track_id": {{random.number(30)}},  
      "activity_type": {{random.weightedArrayElement(
            {
                "weights": [0.1, 0.2, 0.2, 0.3, 0.2],
                "data": ["\"Running\"", "\"Working\"", "\"Walking\"", "\"Traveling\"", "\"Sitting\""]
            }
        )}}
    }
    
    • Then, choose Send data.

    Send Data

  17. After sending approximately ~ 100,000 messages.

    • You can choose Stop Sending Data to Kinesis.

    Stop Sending

  18. Check to ensure that the data has been sent to S3. Access the AWS Management Console.

    • Find S3.
    • Select S3.

    Search S3

  19. In the S3 interface.

    • Select Bucket.
    • Select your S3 bucket.

    Select Bucket

  20. In the Bucket interface.

    • Choose the data folder.

    Data Folder

  21. Select the raw2026 folder inside the data folder.

    • You can see the raw2026/ and reference_data/ folders.

    Raw Data Folder

  22. The data has been successfully sent to S3.

    • You can see the Firehose stream files inside the folder.

    Data in S3