Closed michaelwiles closed 4 years ago
hmmm so having had a look at the tests for dynamodb step functions it looks like this should work:
dynamo_put_task = CallDynamoDB.put_item(item={'id': DynamoAttributeValue().with_s('1234')},
table_name=event_table.table_name, return_values=DynamoReturnValues.ALL_NEW)
But generates template thus:
Type: AWS::StepFunctions::StateMachine
Properties:
DefinitionString:
Fn::Join:
- ""
- - '{"StartAt":"invoke-notification-service","States":{"invoke-notification-service":{"End":true,"Parameters":{"Item":{},"TableName":"'
- Ref: events26E65764
- '","ReturnValues":"ALL_NEW"},"Type":"Task","Resource":"arn:'
- Ref: AWS::Partition
- :states:::dynamodb:putItem"}}}
RoleArn:
Fn::GetAtt:
- saveeventRole24A1910F
- Arn
Notice there is a blank Item.
Of course this is with the
if isinstance(item, dict): item = DynamoAttributeValueMap(**item)
from DynamoPutItemsProps removed.
So I'm beginning to think this is an actual bug in the pyhon sdk...
I've created a repo with a very basic example demonstrates my issue...
https://github.com/Lumkani/cdk-python-step-function-aws-cdk-8108
@michaelwiles - thank you for taking the time to fill in this thorough report and repro! you're absolutely right. our current modeling is not compatible with Python, Java, or C#.
I'm in the middle of rewriting the task implementations for all service integrations and DynamoDB is the next one up. I'll be making some changes to address this problem. They will be breaking changes to the current implementation.
Thank you very much
So I'm really struggling with how to deploy a step function to put an item into a dynamodb table with the python sdk. I eventually want to provide the item via event bridge.
When I get errors I'm not sure if they are real errors or not:
I've tried this:
I really don't know how to use a DynamoAttributeValueMap as this is just a shell in python which is why I'm not using one.
And even for this to run I've had to remove the following line from DynamoPutItemProps:
if isinstance(item, dict): item = DynamoAttributeValueMap(**item)
otherwise I get an "unknown keyword argument id" when I try to run this. Which kinda makes sense as it's trying to unwrap a map and pass it into a constructor that takes no parameters (just self).
A simple example of creating a step function with cdk to write to dynamodb would be very helpful.
I really don't know how to instantiate that map.
The code that I've got - in the example - at least generates the cloudformation template but the item is empty. It is just {}.
When I try to do something like this cause I think that's what I'm supposed to do...
To try and force values into that map I get error:
Just a plain worked example would be useful - though there might also be a bug here...