Using TypeScript and CDK, how do I define a task that prefixes one of the fields of the input and keeps the rest unchanged?
Input:
{
"field1": "foo",
"field2": "bar"
}
Expected output:
{
"field1": "baz_foo",
"field2": "bar"
}
This can be done with a Pass task and intrinsic function States.Format.
const addPrefix = new sfn.Pass(this, 'AddPrefix', {
parameters: {
'field1.$': "States.Format('{}{}', 'baz_', $.field1)",
'field2.$': '$.field2',
},
});