(see sample policy)
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"iot:Publish",
"iot:Subscribe",
"iot:RetainPublish"
],
"Resource": "arn:aws:iot:region:account:*/$aws/things/*/defender/metrics/*"
},
{
"Effect": "Allow",
"Action": "iot:Connect",
"Resource": "arn:aws:iot:region:account:client-*"
}
]
}
Replace with the following with the data from your AWS account:
* ``: The AWS IoT Core region where you created your AWS IoT Core thing you wish to use with this sample. For example `us-east-1`.
* ``: Your AWS IoT Core account ID. This is the set of numbers in the top right next to your AWS account name when using the AWS IoT Core website.
Note that in a real application, you may want to avoid the use of wildcards in your ClientID or use them selectively. Please follow best practices when working with AWS on production applications using the SDK. Also, for the purposes of this sample, please make sure your policy allows a client ID of `test-*` to connect or use `--client_id ` to send the client ID your policy supports.
## How to run
You will need to create a **Security Profile** to see the metric results in the AWS console. You can create a Security Profile by going to `Detect -> Security Profiles` from the AWS IOT Console. To see the custom metrics, you will need to add them in `Detect -> Metrics` and then press the `Create` button to make a new custom metric.
This sample expects and requires the following custom metrics:
* `CustomNumber`
* type: `number`
* info: always sends the number `10`.
* `CustomNumberTwo`
* type `number`
* info: sends a random number from `-50` to `50`.
* `CustomNumberList`
* type `number-list`
* info: sends a predefined list of numbers.
* `CustomStringList`
* type `string-list`
* info: sends a predefined list of strings.
* `CustomIPList`
* type `ip-list`
* info: sends a predefined list of documentation IP addresses.
To run the Device Defender sample, use the following command:
``` sh
./basic-report --endpoint