I'm trying to start an AWS State Machine (step function) once a file is uploaded to an S3 bucket. The bucket already exists and the project was created using Serverless Framework.
For that, I created this function in my serverless.yml
functions:
imagewasuploadedevent:
handler: src/stepfunctions/imageWasUploadedEvent.handler
events:
- s3:
bucket: !Ref AttachmentsBucket
existing: true
iamRoleStatements:
- Effect: "Allow"
Action:
- "states:StartExecution"
Resource:
- "*"
This function should be triggered when a file is uploaded to the S3 bucket "AttachmentsBucket" that already exists and I hope it starts the State Machine processing
Now the Step Function definition is below
stepFunctions:
stateMachines:
ValidateImageStateMachine:
definition:
Comment: "This state function validates the images after users upload them to S3"
StartAt: imagewasuploadedevent
States:
imageWasUploadedEvent:
Type: Task
Resource:
Fn::GetAtt: [imagewasuploadedevent, Arn]
End: true
The plug-ins section is making use of "serverless-step-functions" plugins
plugins:
- serverless-python-requirements
- serverless-iam-roles-per-function
- serverless-step-functions
However, CloudFormation of the stack is failing with the following error
An error occurred:
ValidateImageStateMachineStepFunctionsStateMachine - Invalid State Machine
Definition: 'MISSING_TRANSITION_TARGET: Missing 'Next' target: imagewasuploadedevent at /StartAt, MISSING_TRANSITION_TARGET: State "imageWasUploadedEvent" is not reachable. at /States/imageWasUploadedEvent' (Service: AWSStepFunctions; Status Code: 400; Error Code: InvalidDefinition; Request ID: 39217fe8-9dcd-4386-8549-b995619d2db6; Proxy: null).
I'm suspecting it has nothing to do with I'm doing but the fact that we can only use this plug-in to initiate State Machines through API Gateway functions and schedules and cloud watch events.
Could someone point me here in the right direction?
Thanks