Home > Software engineering >  How to invoke a REST API when an object arrives on S3?
How to invoke a REST API when an object arrives on S3?

Time:02-10

S3 can be configured to invoke lambda when an object arrives in it.

Is it possible to invoke a REST API (endpoint of a microservice running in EKS) when an object arrives in S3?

CodePudding user response:

From November 2021 is possible to integrate S3 with Amazon EventBridge. So you can create an EventBridge rule which is triggered on bucket object creation and has API destination as a target.

For this, the option Bucket Properties -> Amazon EventBridge -> "Send notifications to Amazon EventBridge for all events in this bucket" should be enabled.

Then, on EventBridge create the rule with an event pattern like this:

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

And configure the target as API destination endpoint (configure http method, endpoint, authorization).

CodePudding user response:

You can set up an SNS topic as a target for the event from S3. In the SNS topic, you can add an HTTP/s subscriber, which can be your API endpoint.

CodePudding user response:

Have the Lambda hit the REST API for you.

  • Related