Search code examples
python-3.xaws-cdkaws-step-functions

AWS step function/cdk: cannot add output to catcher


With this smallest example I could come up with:

from aws_cdk import aws_stepfunctions_tasks as tasks
from aws_cdk import aws_stepfunctions as sfn

states = tasks.GlueStartJobRun.jsonata(  # actual type does not matter, this is just have something to catch errors on
    self,
    "Start_job",
    glue_job_name="{% $states.input %}",
).add_catch(
    sfn.Fail.jsonata(self, "boom"),
    errors=["States.ALL"],
    outputs="a string",  # Not appearing!
)

sfn.StateMachine(
    self,
    "State_machine",
    query_language=sfn.QueryLanguage.JSON_PATH,
    definition_body=sfn.ChainDefinitionBody.from_chainable(states),
)

After having deploying with cdk, the catcher of the "Start Job" step does not have any output defined. I can see that even the cloudformation template does not have it. It is not a syntax error, though, and this is documented. Trying with a string or any other data type does not change the issue.

As I am using the latest aws-cdk-lib (2.178.1 at time of writing), I think this is a bug.

I think it should be possible to "manually" override this, with something like add_property_override but I cannot find a way.

How can I have the outputs I define in the the catcher?


Solution

  • This was a bug in the cdk, now fixed. It works as expected.