Create terraform Iot rule and save into dynamodbv2

Hello,

I’m trying to save iot rule capture into a dynamodbv2 as follow :

resource “aws_iot_topic_rule” “topic_rule” {
name = “$some_name”
description = “description”
enabled = true
sql = “query’”
sql_version = “2016-03-23”

dynamodbv2 {
	put_item = [
		            {
	                    table_name = "${var.dynamo_db}"
	                }
		   ]
	role_arn = "${aws_iam_role.roleARN.arn}"
}

}

But I’m getting this error : An argument named “put_item” is not expected here. Did you mean to define a block of type “put_item”?

Does anyone knows why?

Thank’s

put_item is defined as a block, not an assignable argument. This means that the configuration should look like this:

dynamodbv2 {
  put_item {
    table_name = "${var.dynamo_db}"
  }
  role_arn = "${aws_iam_role.roleARN.arn}"
}

Note the lack of = and list brackets []. If you need multiple put_item values, add more put_item { … } blocks.

You can read more on the difference between arguments and blocks in the documentation.