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달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠