Configure storage settings for cold tier (Amazon CLI) - Amazon IoT SiteWise
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Configure storage settings for cold tier (Amazon CLI)

The following procedure shows you how to configure the storage settings to replicate data to the cold tier using Amazon CLI.

To configure storage settings using Amazon CLI
  1. To export data to an Amazon S3 bucket in your account, run the following command to configure the storage settings. Replace file-name with the name of the file that contains the Amazon IoT SiteWise storage configuration.

    aws iotsitewise put-storage-configuration --cli-input-json file://file-name.json
    Example Amazon IoT SiteWise storage configuration
    • Replace bucket-name with your Amazon S3 bucket name.

    • Replace prefix with your Amazon S3 prefix.

    • Replace aws-account-id with your Amazon account ID.

    • Replace role-name with the name of the Amazon S3 access role that allows Amazon IoT SiteWise to send data to Amazon S3.

    • Replace retention-in-days with a whole number than is greater than or equal to 30 days.

    { "storageType": "MULTI_LAYER_STORAGE", "multiLayerStorage": { "customerManagedS3Storage": { "s3ResourceArn": "arn:aws:s3:::bucket-name/prefix/", "roleArn": "arn:aws:iam::aws-account-id:role/role-name" } }, "retentionPeriod": { "numberOfDays": retention-in-days, "unlimited": false } }
    Note
    • You must use the same Amazon S3 bucket name in the Amazon IoT SiteWise storage configuration and IAM policy.

    • Make sure that your role has the permissions shown in the following example.

      Example permissions policy:
      { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "s3:PutObject", "s3:GetObject", "s3:DeleteObject", "s3:GetBucketLocation", "s3:ListBucket" ], "Resource": [ "arn:aws:s3:::bucket-name", "arn:aws:s3:::bucket-name/*" ] } ] }

      Replace bucket-name with the name of your Amazon S3 bucket.

    Example response
    { "storageType": "MULTI_LAYER_STORAGE", "retentionPeriod": { "numberOfDays": 100, "unlimited": false }, "configurationStatus": { "state": "UPDATE_IN_PROGRESS" } }
    Note

    It can take a few minutes for Amazon IoT SiteWise to update the storage configuration.

  2. To retrieve the storage configuration information, run the following command.

    aws iotsitewise describe-storage-configuration
    Example response
    { "storageType": "MULTI_LAYER_STORAGE", "multiLayerStorage": { "customerManagedS3Storage": { "s3ResourceArn": "arn:aws:s3:::DOC-EXAMPLE-BUCKET/torque/", "roleArn": "arn:aws:iam::123456789012:role/SWAccessS3Role" } }, "retentionPeriod": { "numberOfDays": 100, "unlimited": false }, "configurationStatus": { "state": "ACTIVE" }, "lastUpdateDate": "2021-03-30T15:54:14-07:00" }
  3. To stop exporting data to the Amazon S3 bucket, run the following command to configure storage settings.

    aws iotsitewise put-storage-configuration --storage-type SITEWISE_DEFAULT_STORAGE
    Note

    By default, your data is only stored in the hot tier of Amazon IoT SiteWise.

    Example response
    { "storageType": "SITEWISE_DEFAULT_STORAGE", "configurationStatus": { "state": "UPDATE_IN_PROGRESS" } }
  4. To retrieve the storage configuration information, run the following command.

    aws iotsitewise describe-storage-configuration
    Example response
    { "storageType": "SITEWISE_DEFAULT_STORAGE", "configurationStatus": { "state": "ACTIVE" }, "lastUpdateDate": "2021-03-30T15:57:14-07:00" }

(Optional) Create an Amazon IoT Analytics data store (Amazon CLI)

An Amazon IoT Analytics data store is a scalable and queryable repository that receives and stores data. You can use the Amazon IoT SiteWise console or Amazon IoT Analytics APIs to create an Amazon IoT Analytics data store to save your Amazon IoT SiteWise data. To query the data, you create datasets by using Amazon IoT Analytics. For more information, see Working with Amazon IoT SiteWise data in the Amazon IoT Analytics User Guide.

The following steps use Amazon CLI to create a data store in Amazon IoT Analytics.

To create a data store, run the following command. Replace file-name with the name of the file that contains the data store configuration.

aws iotanalytics create-datastore --cli-input-json file://file-name.json
Note
  • You must specify the name of an existing Amazon S3 bucket. If you don't have an Amazon S3 bucket, create one first. For more information, see Create your first S3 bucket in Amazon S3 User Guide.

  • You must use the same Amazon S3 bucket name in the Amazon IoT SiteWise storage configuration, IAM policy, and Amazon IoT Analytics data store configuration.

Example Amazon IoT Analytics data store configuration

Replace data-store-name and s3-bucket-name with your Amazon IoT Analytics data store name and Amazon S3 bucket name.

{ "datastoreName": "data-store-name", "datastoreStorage": { "iotSiteWiseMultiLayerStorage": { "customerManagedS3Storage": { "bucket": "s3-bucket-name" } } }, "retentionPeriod": { "numberOfDays": 90 } }
Example response
{ "datastoreName": "datastore_IoTSiteWise_demo", "datastoreArn": "arn:aws:iotanalytics:us-west-2:123456789012:datastore/datastore_IoTSiteWise_demo", "retentionPeriod": { "numberOfDays": 90, "unlimited": false } }