Menu
AWS IoT
Developer Guide

S3 Action

A s3 action writes the data from the MQTT message that triggered the rule to an Amazon S3 bucket. When creating an AWS IoT rule with an s3 action, you must specify the following information:

bucket

The Amazon S3 bucket to which to write data.

cannedacl

The Amazon S3 canned ACL that controls access to the object identified by the object key. For more information, see S3 Canned ACLs.

key

The path to the file where the data is written. For example, if the value of this argument is "${topic()}/${timestamp()}", the topic the message was sent to is "this/is/my/topic,", and the current timestamp is 1460685389, the data is written to a file called "1460685389" in the "this/is/my/topic" folder on Amazon S3.

Note

Using a static key results in a single file in Amazon S3 being overwritten for each invocation of the rule. More common use cases are to use the message timestamp or another unique message identifier, so that a new file is saved in Amazon S3 for each message received.

roleArn

The IAM role that allows access to the Amazon S3 bucket.

Note

Make sure the role associated with the rule has a policy granting the s3:PutObject permission.

The following JSON example shows how to define an s3 action in an AWS IoT rule:

{ "rule": { "sql": "SELECT * FROM 'some/topic'", "ruleDisabled": false, "actions": [{ "s3": { "roleArn": "arn:aws:iam::123456789012:role/aws_iot_s3", "bucketName": "my-bucket", "key": "${topic()}/${timestamp()}" } }] } }

For more information, see the Amazon S3 Developer Guide.