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ヶ月前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ