Home > Software engineering >  AWS: Trigger step function state machine on s3 object creation using Event Bridge Not Working
AWS: Trigger step function state machine on s3 object creation using Event Bridge Not Working

Time:04-27

I enabled notifications for Amazon EventBridge on my s3 bucket. enter image description here

Then I created an EventBridge rule with the following event pattern:

{
  "detail": {
    "bucket": {
      "name": ["arn:aws:s3:::my-bucket"]
    }
  },
  "detail-type": ["Object Created"],
  "source": ["aws.s3"]
}

Then I added my state machine as the target of this rule. I also attached an IAM role with the following policy for this event target.

"Statement": [
        {
            "Effect": "Allow",
            "Action": [ "states:StartExecution" ],
            "Resource": [ "arn:aws:states:*:*:stateMachine:*" ]
        }
    ]

Then I attached the following policy to my state machine step function as well:

{ 
        "Action": "events:*", 
        "Resource": "arn:aws:events:us-east-1:my-account-id:event-bus/default", 
        "Effect": "Allow" 
      }

After doing all of this, still my state machine is not getting invoked. enter image description here

What am I missing here? How can I debug where the issue might be?

CodePudding user response:

Have you checked if your custom pattern matches the event? I think you do not need arn in the name. Try with

{
  "detail": {
    "bucket": {
      "name": ["my-bucket"]
    }
  },
  "detail-type": ["Object Created"],
  "source": ["aws.s3"]
}
  • Related