Closed knihit closed 3 years ago
When a StateMachine is constructed, it uses the state graph to both render a definition as well as assign the appropriate permissions. Due to the way synthesis occurs (bottom-up), I don't believe it's possible to support "as-you-go" state machine definition, even with a major re-working of how we go about it currently. Is there a particular reason why you want to construct the state machine before the definition has been finalized?
So my use case was to use SqsSendMessage. So as part of this I have an SQS queue and a lambda function. This lambda function requires policy permissions to [ 'states:SendTaskSuccess', 'states:sendTaskFailure', 'states:SendTaskHeartbeat' ]
to let the state machine know that the task is complete. I wanted to narrow down the resources
to the state machine but if the machine is not available it would have to be '*'. Defining the machine in the beginning would allows the policy to have the resource arn to be specified in the lambda policy. I understand your viewpoint. I am trying to think how to rearrange my construct structure so that I can attach that policy later once the definition and state machine is created. Appreciate your help.
Hey @knihit have you made any progress here?
I am trying to think how to rearrange my construct structure so that I can attach that policy later once the definition and state machine is created
Do you have any additional questions?
Hi @peterwoodworth, for the immediate future I have decided to have the resources as '*' in the policy, For future refactoring, I am planning to add a method to the construct class I created, which I can invoke post the statemachine is created. Since I am using the stepfunction callback integration pattern where the task is published to SQS with a task token, I do have the flexibility to define the lambda (consumer of the SQS queue) IAM policy (for sendTaskSuccess/ Failure/ Heartbeat) once the stepfunction workflow is instantiated. If Cloudformation dependencies for are not resolved automatically for any reason here, I can add 'DependsOn' clauses to make it work. This is how I plan to solve it. If there are any other suggestions, please let me know.
Let me know if that works out for you, and if not feel free to ask any questions
Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.
If the state machine definition was created before the defining the complete Chain, the definition string does not contain the task states.
Reproduction Steps
Below are two code samples the first creates the definition string correctly, but the second one does not. Notice that the statement is created as the last step, in the first code sample.
Working sample
Second sample
What did you expect to happen?
The first and second code should generate the same definition string, if not it should throw an error because here the sequence of statements should not matter.
What actually happened?
The definition string for the state machine with the second example was undeployable and CloudFormation returned an error.
Environment
Other
Definition string from the first code sample.
Definition string from second code sample
This is :bug: Bug Report