I'm wondering if is there a way to get the bucket key from the input via CDK?
In the console, we can define:
"ItemReader": {
"Resource": "arn:aws:states:::s3:getObject",
"ReaderConfig": {
"InputType": "JSON"
},
"Parameters": {
"Bucket": "my-bucket",
"Key.$": "$.key"
}
}
But this doesn't seem to be working in CDK:
const map = new sfn.DistributedMap(this, 'Parse the document', {
itemReader: new sfn.S3JsonItemReader({
bucket: myBucket,
key: '$.key',
}),
})
Use the CDK's JsonPath.stringAt helper method to use the
$.keyvalue from the state machine input:That will synth the expected
"Key.$": "$.key"SDL. Your code outputs"Key": "$.key", which will cause step functions to treat$.keyas a literal string.