Skip to content
v2.278.0

DynamoDBActionProperty ​

Struct External

Describes an action to write to a DynamoDB table.

The tableName , hashKeyField , and rangeKeyField values must match the values used when you created the table.

The hashKeyValue and rangeKeyvalue fields use a substitution template syntax. These templates provide data at runtime. The syntax is as follows: ${ sql-expression }.

You can specify any valid expression in a WHERE or SELECT clause, including JSON properties, comparisons, calculations, and functions. For example, the following field uses the third level of the topic:

"hashKeyValue": "${topic(3)}"

The following field uses the timestamp:

"rangeKeyValue": "${timestamp()}"

For more information, see DynamoDBv2 Action in the AWS IoT Developer Guide .

Example ​

ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_iot as iot } from 'aws-cdk-lib';
const dynamoDBActionProperty: iot.CfnTopicRule.DynamoDBActionProperty = {
  hashKeyField: 'hashKeyField',
  hashKeyValue: 'hashKeyValue',
  roleArn: 'roleArn',
  tableName: 'tableName',

  // the properties below are optional
  hashKeyType: 'hashKeyType',
  payloadField: 'payloadField',
  rangeKeyField: 'rangeKeyField',
  rangeKeyType: 'rangeKeyType',
  rangeKeyValue: 'rangeKeyValue',
};
python
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
from aws_cdk import aws_iot as iot

dynamo_db_action_property = iot.CfnTopicRule.DynamoDBActionProperty(
    hash_key_field="hashKeyField",
    hash_key_value="hashKeyValue",
    role_arn="roleArn",
    table_name="tableName",

    # the properties below are optional
    hash_key_type="hashKeyType",
    payload_field="payloadField",
    range_key_field="rangeKeyField",
    range_key_type="rangeKeyType",
    range_key_value="rangeKeyValue"
)
java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.services.iot.*;

DynamoDBActionProperty dynamoDBActionProperty = DynamoDBActionProperty.builder()
        .hashKeyField("hashKeyField")
        .hashKeyValue("hashKeyValue")
        .roleArn("roleArn")
        .tableName("tableName")

        // the properties below are optional
        .hashKeyType("hashKeyType")
        .payloadField("payloadField")
        .rangeKeyField("rangeKeyField")
        .rangeKeyType("rangeKeyType")
        .rangeKeyValue("rangeKeyValue")
        .build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK.AWS.IoT;

var dynamoDBActionProperty = new DynamoDBActionProperty {
    HashKeyField = "hashKeyField",
    HashKeyValue = "hashKeyValue",
    RoleArn = "roleArn",
    TableName = "tableName",

    // the properties below are optional
    HashKeyType = "hashKeyType",
    PayloadField = "payloadField",
    RangeKeyField = "rangeKeyField",
    RangeKeyType = "rangeKeyType",
    RangeKeyValue = "rangeKeyValue"
};
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import "github.com/aws/aws-cdk-go/awscdk"

dynamoDBActionProperty := &DynamoDBActionProperty{
	HashKeyField: jsii.String("hashKeyField"),
	HashKeyValue: jsii.String("hashKeyValue"),
	RoleArn: jsii.String("roleArn"),
	TableName: jsii.String("tableName"),

	// the properties below are optional
	HashKeyType: jsii.String("hashKeyType"),
	PayloadField: jsii.String("payloadField"),
	RangeKeyField: jsii.String("rangeKeyField"),
	RangeKeyType: jsii.String("rangeKeyType"),
	RangeKeyValue: jsii.String("rangeKeyValue"),
}

Properties ​

hashKeyFieldstringhash_key_fieldstrhashKeyFieldStringHashKeyFieldstringHashKeyField*string required #
The hash key name.
hashKeyTypeoptionalstringhash_key_typeoptionalstrhashKeyTypeoptionalStringHashKeyTypeoptionalstringHashKeyTypeoptional*string #
The hash key type.

Valid values are "STRING" or "NUMBER"

hashKeyValuestringhash_key_valuestrhashKeyValueStringHashKeyValuestringHashKeyValue*string required #
The hash key value.
payloadFieldoptionalstringpayload_fieldoptionalstrpayloadFieldoptionalStringPayloadFieldoptionalstringPayloadFieldoptional*string #
The action payload.

This name can be customized.

rangeKeyFieldoptionalstringrange_key_fieldoptionalstrrangeKeyFieldoptionalStringRangeKeyFieldoptionalstringRangeKeyFieldoptional*string #
The range key name.
rangeKeyTypeoptionalstringrange_key_typeoptionalstrrangeKeyTypeoptionalStringRangeKeyTypeoptionalstringRangeKeyTypeoptional*string #
The range key type.

Valid values are "STRING" or "NUMBER"

rangeKeyValueoptionalstringrange_key_valueoptionalstrrangeKeyValueoptionalStringRangeKeyValueoptionalstringRangeKeyValueoptional*string #
The range key value.
roleArnstringrole_arnstrroleArnStringRoleArnstringRoleArn*string required #
The ARN of the IAM role that grants access to the DynamoDB table.
tableNamestringtable_namestrtableNameStringTableNamestringTableName*string required #
The name of the DynamoDB table.