Deployed Fargate Task when object uploaded to S3

0

I have a scenario where I need to deploy a Fargate task when an object is uploaded to an S3 bucket. I know that I can introduce a Lambda function in between to deploy the task, but is it possible to use EventBridge to deploy the task without a queue or Lambda function?

AWS
已提问 5 个月前188 查看次数
2 回答
1
已接受的回答

You can use EventBridge to deploy an ECS task. However, even if the ECS task is deployed, the container will not receive the event details such as the S3 bucket name and key by default. One solution is to configure the target input in EventBridge rule to override the environment variables of the container. This way, the container can perform the job based on the S3 bucket name and key.

Follow these steps (assuming that S3 is the source event):

  1. In the EventBridge, select ECS as the target.
  2. Update the 'Configure target input' to 'Input Transformer' and configure the input transformer.
  3. Update the 'Target input transformer' to define the variables and assign each value based on the event before EventBridge passes it to the target. Example: {"bucketname":"$.detail.bucket.name","keyname":"$.detail.object.key"}
  4. Update the 'Input Template' to pass the information to the target. In this step, pass the variables defined in Step 3 and override the environment variables of the container using the containerOverride command. In Step 3, we defined bucketname as the variable name and passes the bucket name from the event. To use the variable, define <bucketname> to use the value. {"containerOverrides": [{"name":"containerName","environment":[{"name":"BUCKETNAME","value":"<bucketname>"},{ "name":"S3_KEY","value":"<keyname>" }]}]} Note: the name is the container name that you assign in the task definition.
  5. Your container will be able to access the environment variables 'BUCKETNAME' and 'S3_KEY'.
已回答 5 个月前
1

Hello.

It should probably be possible since you can select ECS Task as the target of EventBridge.
https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-targets.html

From the management console, you can select ECS Task when creating an EventBridge rule as shown below, so you can probably start it.
a

profile picture
专家
已回答 5 个月前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则