aws / aws/jsii

(iot) CfnTopic dynamoDBv2 keyword improperly translated in code snippets seen in documentation

Open
#3,831 0 comments 0 reactions 0 assignees View on GitHub
bug documentation p2
Dominant language
TypeScript
Stars
2.9k
Forks
267
Avg merge
1d 25m
Merged PRs (30d)
14

Description

### Describe the bug

**This seems more like a minor bug rather than a documentation issue.**

In the `aws_iot` library when creating a `CfnTopicRule`, and defining a `DynamboDBv2ActionProperty` for the `TopicRulePayloadProperty` I get an unexpected keyword argument error for `dynamo_dBv2`.

The [documentation](https://docs.aws.amazon.com/cdk/api/v2/python/aws_cdk.aws_iot/CfnTopicRule.html#actionproperty) specifies this should be the correct keyword.

When I look at the `CfnTopicRule.ActionProperty` class the expected keyword is `dynamo_d_bv2`.

### Expected Behavior

Defining `dynamo_dBv2` as a keyword argument for the `CfnTopicRule.ActionProperty` doesn't throw and error.

### Current Behavior

Defining `dynamo_dBv2` as a keyword argument for the `CfnTopicRule.ActionProperty` throws and error.

`TypeError: CfnTopicRule.ActionProperty.__init__() got an unexpected keyword argument 'dynamo_dBv2'`

### Reproduction Steps

```
from aws_cdk import (
# Duration,
Stack,
aws_iot as iot,
aws_dynamodb as dynamodb,
aws_iam as iam
)
from constructs import Construct

class EnviroDigitalTwinStack(Stack):
#Create role to allow iot access dynamodb service
role = iam.Role(self, "Twin2DigitalEntity",
assumed_by=iam.ServicePrincipal("iot.amazonaws.com")
)

role.add_to_policy(iam.PolicyStatement(
resources=["*"],
actions=["dynamodb:*"]
))

# Create Dynamo Table
readings_table = dynamodb.Table(
self, "enviro-twin-2",
partition_key=dynamodb.Attribute(
name="time",
type=dynamodb.AttributeType.STRING
)
)
sql_stmt = f"SELECT * FROM 'enviro/{cfn_thing.thing_name}'"
cfn_topic_rule = iot.CfnTopicRule(self, id="MyCfnTopicRule",
topic_rule_payload=iot.CfnTopicRule.TopicRulePayloadProperty(
actions=[iot.CfnTopicRule.ActionProperty(
dynamo_dBv2=iot.CfnTopicRule.DynamoDBv2ActionProperty(
put_item=iot.CfnTopicRule.PutItemInputProperty(
table_name=readings_table.table_name
),
role_arn=role.role_arn
)
)],
sql=sql_stmt,
rule_disabled=False
)
)
```

Running `cdk synth` should raise the error.

### Possible Solution

Update the `CfnTopicRule.ActionProperty` argument `dynamo_d_bv2` to `dynamo_dBv2` and any reference to it in the class.

OR

Update the documentation

### Additional Information/Context

_No response_

### CDK CLI Version

2.47.0

### Framework Version

_No response_

### Node.js Version

v16.18.0

### OS

macOS Monterey v12.6

### Language

Python

### Language Version

Python 3.10.4

### Other information

_No response_

Contributor guide

Open the contributing guide

Research direction

Start with the CfnTopicRule.ActionProperty API and the linked Python documentation, then reproduce the reported cdk synth failure using the example. Determine whether the generated keyword or the documentation is incorrect; done means the documented and accepted keyword agree and the reproduction no longer raises the unexpected-keyword error.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, python, typescript
Domain
developer-experience, documentation, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.